Home  >  Article  >  Backend Development  >  PHP header函数的详细用法介绍_PHP教程

PHP header函数的详细用法介绍_PHP教程

WBOY
WBOYOriginal
2016-07-15 13:32:07883browse

我们今天要为大家介绍的是有关

// PHP header函数向浏览器发送404 状态码
header(“HTTP/1.1 404 Not Found”);
或者
header(“HTTP/1.1 404″);

// PHP header函数永久重定向
header(“Location: http://weizhifeng.net/”);//默认是301 跳转
// 临时重定向
header(“HTTP/1.1 302 Found”);
header(“Location: http://weizhifeng.net/”);


// PHP header函数下载文件
header(“Content-type: text/plain’); // 可以替换成你需要的MIME类型
header(‘Content-Disposition: attachment; filename=”weizhifeng.txt”‘);
readfile(‘weizhifeng.txt’);


其他的头信息可以参考HTTP/1.1 specification
如果在PHP header函数之前已经有了输出,那么请使用ob_start()函数。
 


www.bkjia.comtruehttp://www.bkjia.com/PHPjc/446156.htmlTechArticle我们今天要为大家介绍的是有关 // PHP header函数向浏览器发送404 状态码 header(HTTP/1.1 404 Not Found); 或者 header(HTTP/1.1 404); // PHP header函数永久重...
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