Home >Backend Development >PHP Tutorial >How to convert header status code in PHP_PHP tutorial

How to convert header status code in PHP_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 17:23:44801browse

As described in Mr. Peng Wuxing's "PHP BIBLE", the header can send a Status header, such as , which can cause the user's browser to display a 404 error of file not found, but I tried this and it didn't work. Later, I checked http-related information on w3.org, and finally figured out how to display the status code (Status) in the header, and shared it with everyone. In fact, it should be like this: Header("http/1.1 403 Forbidden"); ?> The first part is the version of the HTTP protocol (HTTP-Version), the second part is the status code (Status), and the third part is the reason phrase (Reason-Phrase) ) The three parts are separated by a space, and there cannot be a carriage return in the middle. The first and second parts are required, and the third part is for people to read. You can write it or not or even write it randomly. Also, the output of this sentence must be on the first line of the Html file. Below I give the meaning of each code (I found it from w3.org, it is authoritative enough): * 1xx: Informational - Request received, continuing process * 2xx: Success - The action was successfully received, understood, and accepted * 3xx: Redirection - Further action must be taken in order to complete the request * 4xx: Client Error - The request contains bad syntax or cannot be fulfilled * 5xx: Server Error - The server failed to fulfill an apparently valid request * 5xx: "100 " ; Continue | "101" ; Switching Protocols | "200" ; OK " | "201" ; Created " | "202" ; Accepted " | "203" ; Content     | "206" ; Partial Content      | "300" ; Multiple Choices      | "301" ; Moved Permanently y | "400" ; Bad Request | "401" ; Unauthorized | "402" ; Payment Required | "403" ; Forbidden | "404" ; Not Found | "405" ; Not Allowed Method | "406" ; Not Acceptable | " 407" ; Proxy Authentication Required      | "408" ; Request Time-out      | "409" ; quest Entity Too Large | "414" ; Request-URI Too Large | "415" ; Unsupported Media Type | "500" ; Internal Server Error | "501" ; Not Implemented | "502" ; Bad Gateway | "503" ; Service Unavailable | "504" " ; Gateway Time-out     | "505" ; HTTP Version not supported

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/532199.htmlTechArticleAs mentioned in Mr. Peng Wuxing's "PHP BIBLE", the header can send the Status header, such as A 404 file not found error appeared in the user's browser, but it didn't work when I tried this...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn