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 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 tried 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 HTTP protocol version (HTTP-Version)
The second part is the status code (Status)
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 Yes, 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