How to use header to send header information in PHP
Source: Internet
Author: User
According to Mr. Peng Wuxing's PHP Le, the header can send the Status header, as shown in
Header ("Status: 404 Not Found ");
?>
In this way, the user's browser can see the 404 error that the file cannot be found, but I tried this.
Later, I checked the relevant http information on w3.org and finally found out how to output the Status code (Status) in the Header to share with you.
It should actually be like this:
Header ("http/1.1 403 Forbidden ");
?>
The first part is the HTTP Version)
The second part is Status code)
Part 3: Reason Phrase (Reason-Phrase)
Separate the three parts with a space in the middle, and there is no carriage return in the middle. The first part and the second part are required. The third part is for people to see and can be written or not written or even written in disorder.
Also, the output of this sentence must be in the first line of the Html file.
Below I will show the meaning of each code (it was found on w3.org and authoritative enough ):
* 1xx: Informational-Request received, continuing process
* 2xx: Success-The action was successfully pinned ed, understood,
And accepted
* 3xx: Redirection-Further action must be taken in order
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
| "100"; Continue
| "101"; Switching Protocols
| & Quot; 200 & quot; OK
| & Quot; 201 & quot; Created
| "202"; Accepted
| "203"; Non-Authoritative Information
| "204"; No Content
| & Quot; 205 & quot; Reset Content
| "206"; Partial Content
| "300"; Multiple Choices
| "301"; Moved Permanently
| "302"; Moved Temporarily
| "303"; See Other
| & Quot; 304 & quot; Not Modified
| "305"; Use Proxy
| "400"; Bad Request
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.