现在的位置: 首页 > web前端 > 正文

header 404写法和使用

2020年07月17日 web前端 ⁄ 共 1040字 ⁄ 字号 评论关闭

  用PHPheader()函数实现页面404错误提示功能,特整理了PHPheader()函数的详细使用分享给大家,需要大家多多支持我们。


  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


  总之,phpheader404给大家简单的介绍了一些,希望大家多看看。

抱歉!评论已关闭.