当前位置:Gxlcms > PHP教程 > PHP函数header发放HTTP头信息_PHP教程

PHP函数header发放HTTP头信息_PHP教程

时间:2021-07-01 10:21:17 帮助过:26人阅读

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

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

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

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


www.bkjia.comtruehttp://www.bkjia.com/PHPjc/445995.htmlTechArticle// 向浏览器发送404 状态码 header(HTTP/1.1 404 Not Found); 或者 header(HTTP/1.1 404); // 永久重定向 header(Location: http://weizhifeng.net/);//默认是301 跳转 //...

人气教程排行