溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

php如何返回錯誤代碼

發布時間:2021-09-14 17:14:33 來源:億速云 閱讀:315 作者:小新 欄目:編程語言

這篇文章主要介紹php如何返回錯誤代碼,文中介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們一定要看完!

1、用header()函數是可以為返回頁面添加404的頭信息的。

2、提示瀏覽器該網頁找不到了。

所以可以使用:

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狀態的跳轉,所以它是不能給瀏覽器輸出404錯誤狀態的。

以上是“php如何返回錯誤代碼”這篇文章的所有內容,感謝各位的閱讀!希望分享的內容對大家有幫助,更多相關知識,歡迎關注億速云行業資訊頻道!

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

php
AI

亚洲午夜精品一区二区_中文无码日韩欧免_久久香蕉精品视频_欧美主播一区二区三区美女