How to use header to send header information in PHP_PHP Tutorial

WBOY
Release: 2016-07-20 10:59:50
Original
712 people have browsed it

​ As described in Mr. Peng Wuxing's "PHP BIBLE", the header can send the Status header, such as
header("Status: 404 Not Found");
?>
It can cause the user's browser to display a 404 file not found error, 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)
The third part is 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, which 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
     | "100" ; Continue
     | "101" ; Switching Protocols
     | "200" ; OK
     | "201" ; Created
    | "202" ; Accepted
     | "203" ; Non-Authoritative Information
     | "204" ; No Content
     | "205" ; Reset Content
    | "206" ; Partial Content
| "300" ; Multiple Choices
    | "301" ; Moved Permanently
    | "302" ; Moved Temporarily
     | "303" ; See Other
     | "304" ; Not Modified
     | "305" ; Use Proxy
     | "400" ; Bad Request

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/445586.htmlTechArticleAs described in Mr. Peng Wuxing's "PHP BIBLE", the header can send the Status header, such as header(Status : 404 Not Found); ? It can cause the user's browser to display a 404 error of file not found,...
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!