Home >php教程 >php手册 >PHP header()函数常用方法

PHP header()函数常用方法

WBOY
WBOYOriginal
2016-06-13 09:38:02787browse

//定义编码

//Atom

//CSS

//Javascript

//JPEG Image

//JSON

//PDF

//RSS

//Text (Plain)

//XML

// ok

//设置一个404头:

//设置地址被永久的重定向

//转到一个新地址

//文件延迟转向:
print 'You will be redirected in 10 seconds';
//当然,也可以使用html语法实现
// header('Content-Transfer-Encoding: binary');
// load the file to send:
readfile('example.zip');
// 对当前文档禁用缓存
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
header('Pragma: no-cache');
//设置内容类型:
header('Content-Type: text/html; charset=utf-8');
header('Content-Type: text/plain'); //纯文本格式
header('Content-Type: image/jpeg'); //JPG***
header('Content-Type: application/zip'); // ZIP文件
header('Content-Type: application/pdf'); // PDF文件
header('Content-Type: audio/mpeg'); // 音频文件
header('Content-Type: application/x-shockw**e-flash'); //Flash动画
//显示登陆对话框
header('WWW-Authenticate: Basic realm="Top Secret"');
print 'Text that will be displayed if the user hits cancel or ';
print 'enters wrong login data';
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn