新聞中心
這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
php如何返回錯誤代碼
這篇文章主要介紹php如何返回錯誤代碼,文中介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們一定要看完!
網(wǎng)站建設哪家好,找創(chuàng)新互聯(lián)建站!專注于網(wǎng)頁設計、網(wǎng)站建設、微信開發(fā)、成都小程序開發(fā)、集團企業(yè)網(wǎng)站建設等服務項目。為回饋新老客戶創(chuàng)新互聯(lián)還提供了黃巖免費建站歡迎大家使用!
1、用header()函數(shù)是可以為返回頁面添加404的頭信息的。
2、提示瀏覽器該網(wǎng)頁找不到了。
所以可以使用:
header("HTTP/1.0 404 Not Found");
或者:
header("Status: 404 Not Found");
后者是在FastCGI模式下使用的,在php代碼中可以把兩句直接同時寫上。
header使用說明如下:
The header string.There are two special-case header calls. The first is a header that starts with the string "HTTP/" (case is not significant), which will be used to figure out the HTTP status code to send. For example, if you have configured Apache to use a PHP script to handle requests for missing files (using the ErrorDocument directive), you may want to make sure that your script generates the proper status code.For FastCGI you must use the following for a 404 response:
而header("Location: xxx.com");默認是做302狀態(tài)的跳轉,所以它是不能給瀏覽器輸出404錯誤狀態(tài)的。
以上是“php如何返回錯誤代碼”這篇文章的所有內(nèi)容,感謝各位的閱讀!希望分享的內(nèi)容對大家有幫助,更多相關知識,歡迎關注創(chuàng)新互聯(lián)行業(yè)資訊頻道!
當前標題:php如何返回錯誤代碼
文章鏈接:http://www.dlmjj.cn/article/ghposs.html