head first c Chinese version header function usage instructions

WBOY
Release: 2016-07-29 08:35:11
Original
1308 people have browsed it

1. Function:
~~~~~~~~~
PHP only sends the header of the HTML document to the browser using the HTTP protocol, telling the browser how to process this page. As for the transmitted content, you need to be familiar with the HTTP protocol. No, it has nothing to do with PHP. Please 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

First, let’s understand how the HTTP protocol works
~~~~~~~~~ ~~~~~ ~~~~~~~~~~~~~~~~~~~
The 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. The 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 issues a request for connection, and the server establishes the connection; then, the client issues an HTTP request (Request), and the server returns response information (Respond), thereby completing an HTTP operation.

3. The meaning of the HTTP protocol status code
~~~~~~~~~~~~~~~~~~~~~~~~~~~
 1×× Reserved
 2×× Indicates The request was successfully received
3×× The customer needs to further refine the request to complete the request
4×× Customer error
5×× Server error
IV. Operation examples:
~~~~~~~~~~~~~
<1> Redirect function, this is the most common
                                                                                                                                                                                                                                                              ​ Get the latest data when the page is running, rather than using the client's cache.​
                                                                                                                                                                                                                                         to ...
          header("Expires: Mon, 26 Jul 1970 05:00:00 GMT");                                   // Tell the browser the last updated date of this page (expressed in Greenwich Mean Time), which is the same day, the purpose is to force the browser to obtain Latest information
      header("Last-Modified: " . gmdate("D, d M Y H:i:s")          "GMT"); er("Cache- Control: No-Cache, Must-Revalidate ");
// parameters (compatible with previous servers), that is, compatible with the HTTP1.0 protocol
header (" Pragma: no-Cache "); ("Content-type: application/file");                                                                                                                                                                                  header("Accept-Ranges: bytes");                                                /The name of the file in the dialog box in the default file
Header ("Content -Disposition: Attachment; FILENAME = $ FILENAME");
? & GT;
& LT; 3 & GT; Control t & lt;? PHP
Header ('HTTP/1.1 401 Unauthorized');
Header ('STATUS: 401 Unauthorized');
? & Gt; 04 , as shown below, so the browser will display that the page does not exist
                                                                                                                                                                                                                  
?>
The above introduces the instructions for using the header function of head first c Chinese version, including the content of head first c Chinese version. I hope it will be helpful to friends who are interested in PHP tutorials.


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!