Instructions for using the header() function:
1. Function:
~~~~~~~~~
PHP only sends the header of the HTML document using the HTTP protocol Go to the browser and tell the browser how to process this page. As for the transmitted content, you need to be familiar with the HTTP protocol. It has nothing to do with PHP. You can refer to http://www.w3.org/Protocols/rfc2616/rfc2616.
Traditional headers must contain one of the following three headers and can only appear once.
Location: xxxx:yyyy/zzzz
Content-Type: xxxx/yyyy
Status: nnn xxxxxx
Second, let’s first understand how the HTTP protocol operates
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HTTP protocol is based on the request/response paradigm. After a client establishes a connection with the server, it sends a request to the server. The format of the request is a uniform resource identifier, a protocol version number, followed by MIME information including request modifiers, client information and possible content. After receiving the request, the server gives corresponding response information. Its format is a status line including the protocol version number of the information, a success or error code, followed by MIME information including server information, entity information and possible content.
It is divided into four processes. In the HTTP protocol, the server refers to the part that provides HTTP services, and the client refers to the browser or download tool you use, etc. During communication, the client sends a request for connection, and the server establishes the connection; then, the client sends an HTTP request (Request), and the server returns response information (Respond), thus completing an HTTP operation.
3. The meaning of HTTP protocol status code
~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~
1×× Reserved
2×× Indicates that the request was successfully received
3×× In order to complete the request, the customer needs to further refine the request
4×× Customer error
5×× Server Error
4. Operation examples:
~~~~~~~~~~~~~
<1> Redirect function, this is the most common