php常见的header操作-成都快上网建站

php常见的header操作

  1. 404:
    header ("HTTP/1.1 404 Not Found");
  2. 301:
    header ("HTTP/1.1 301 Moved Permanently"); 
    header ("Location:http://www.baidu.com");
  3. 下载文件:
    header ('Content-type: application/file');
    header ("Content-Disposition: attachment; filename='test.file'");
    readfile ("test.file");
  4. 允许跨域:
    header('Access-Control-Allow-Origin:*');
  5. 设置自定义header头:
    header('Access-Control-Allow-Headers:WWW-Authenticate,Authorization,Set-Cookie,X-Requested-With, Accept, Accept-Version, Content-Length, Content-MD5, Content-Type, Date, X-Api-Version,name');

文章题目:php常见的header操作
新闻来源:http://kswjz.com/article/gogcjs.html
扫二维码与项目经理沟通

我们在微信上24小时期待你的声音

解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流