luoson1 发表于 2018-12-18 07:31:23

PHP 使用header函数设置HTTP头的示例方法 表头

  原文 :http://www.cnblogs.com/yun007/p/3794044.html
  转载 http://justcoding.iteye.com/blog/601117/
  //定义编码
  header( 'Content-Type:text/html;charset=utf-8 ');
  //Atom
  header('Content-type: application/atom+xml');
  //CSS
  header('Content-type: text/css');
  //Javascript
  header('Content-type: text/javascript');
  //JPEG Image
  header('Content-type: image/jpeg');
  //JSON
  header('Content-type: application/json');
  //PDF
  header('Content-type: application/pdf');
  //RSS
  header('Content-Type: application/rss+xml; charset=ISO-8859-1');
  //Text (Plain)
  header('Content-type: text/plain');
  //XML
  header('Content-type: text/xml');
  // ok
  header('HTTP/1.1 200 OK');
  //设置一个404头:
  header('HTTP/1.1 404 Not Found');
  //设置地址被永久的重定向
  header('HTTP/1.1 301 Moved Permanently');
  //转到一个新地址
  header('Location: http://www.example.org/');
  //文件延迟转向:
  header('Refresh: 10; url=http://www.example.org/');
  print 'You will be redirected in 10 seconds';
  //当然,也可以使用html语法实现
  //
页: [1]
查看完整版本: PHP 使用header函数设置HTTP头的示例方法 表头