PHP中header()怎么用

PHP中header()怎么用

小编给大家分享一下PHP中header()怎么用,相信大部分人都还不怎么了解,因此分享这篇文章给大家参考一下,希望大家阅读完这篇文章后大有收获,下面让我们一起去了解一下吧!

  用PHPheader()函数实现页面404错误提示功能

  phpheader404写法:

  header("HTTP/1.1404NotFound");exit;

  如果以上代码不凑效,可以试试以下代码:

  header("Status:404NotFound");

  最好两段代码都写上.为什么一段代码可以,一段不行呢?我也不清楚,反正最好的写法如下:

  header("HTTP/1.1404NotFound");

  header("Status:404NotFound");

  exit;

  多说一句,这段代码必须在任何输出之前执行!

  更多phpheader函数用法请查阅:http://tuzwu.iteye.com/blog/search?query=header

  http状态码所代表的意思(是从w3.org上查到的,够权威了):

  *1xx:Informational-Requestreceived,continuingprocess

  *2xx:Success-Theactionwassuccessfullyreceived,understood,

  andaccepted

  *3xx:Redirection-Furtheractionmustbetakeninorderto

  completetherequest

  *4xx:ClientError-Therequestcontainsbadsyntaxorcannotbe

  fulfilled

  *5xx:ServerError-Theserverfailedtofulfillanapparently

  validrequest

  |"100";Continue

  phpheader404类似函数

  |"101";SwitchingProtocols

  |"200";OK

  |"201";Created

  |"202";Accepted

  |"203";Non-AuthoritativeInformation

  |"204";NoContent

  |"205";ResetContent

  |"206";PartialContent

  |"300";MultipleChoices

  |"301";MovedPermanently

以上是“PHP中header()怎么用”这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注行业资讯频道!