小編給大家分享一下PHP中header()怎么用,相信大部分人都還不怎么了解,因此分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后大有收獲,下面讓我們一起去了解一下吧!
用PHPheader()函數(shù)實(shí)現(xiàn)頁(yè)面404錯(cuò)誤提示功能
phpheader404寫(xiě)法:
header("HTTP/1.1404NotFound");exit;
如果以上代碼不湊效,可以試試以下代碼:
header("Status:404NotFound");
好兩段代碼都寫(xiě)上.為什么一段代碼可以,一段不行呢?我也不清楚,反正好的寫(xiě)法如下:
header("HTTP/1.1404NotFound");
header("Status:404NotFound");
exit;
多說(shuō)一句,這段代碼必須在任何輸出之前執(zhí)行!
更多phpheader函數(shù)用法請(qǐng)查閱:http://tuzwu.iteye.com/blog/search?query=header
http狀態(tài)碼所代表的意思(是從w3.org上查到的,夠權(quán)威了):
*1xx:Informational-Requestreceived,continuingprocess
*2xx:Success-Theactionwassuccessfullyreceived,understood,
andaccepted
*3xx:Redirection-Furtheractionmustbetakeninorderto
completetherequest
*4xx:ClientError-Therequestcontainsbadsyntaxorcannotbe
fulfilled
*5xx:ServerError-Theserverfailedtofulfillanapparently
validrequest
|"100";Continue
phpheader404類(lèi)似函數(shù)
|"101";SwitchingProtocols
|"200";OK
|"201";Created
|"202";Accepted
|"203";Non-AuthoritativeInformation
|"204";NoContent
|"205";ResetContent
|"206";PartialContent
|"300";MultipleChoices
|"301";MovedPermanently
以上是“PHP中header()怎么用”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對(duì)大家有所幫助,如果還想學(xué)習(xí)更多知識(shí),歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道!