In many development, we try to use header ("Content-type:image/jpeg") to output pictures, try to use some PHP image processing technology, make the output picture more intelligent and dynamic. But we often encounter new problems, unless you specify
The header () function sends the original HTTP header to the client.
It is important to recognize that the header () function must be invoked before any actual output is sent (in PHP Tutorial 4 and later, you can use output caching to solve this
The header () function sends the original HTTP header to the client.
Copy Code code as follows:
200 normal state
Header (' http/1.1 OK ');
301 permanent Redirect, remember to add a redirect to the following address Location: $url
Header () Function usage Description:
first, the role:~~~~~~~~~
PHP is only the HTTP protocol to the HTML document to the browser, tell the browser how to deal with this page, as for the transfer of the content you need to familiarize yourself
Copy Code code as follows:
/*** function:php Header () examples (PHP)
* * Desc:some examples on the header () function of phpyou find a detailed tutorial at expertsrt.com (中文版) o R at Ffm.junetz.de (German). These are also a good help about
The Header () function-is used to send raw HTTP headers.1. redirectHeader ("location:http://www.jb51.net";);Exit After each redirect, "Exit" must be added to avoid an error and continue execution.?>Header ("refresh:2;url=http://www.jb51.net";);echo "
The movie site provides bt download for the movie. Because the Polaroid player is used, a hash file of the movie will be uploaded at the same time when uploading the movie. This hash file is used to dynamically generate the corresponding bt seed for
Php removes the leading and trailing spaces, and php removes the trailing spaces. Php two methods to remove leading and trailing spaces. php two seemingly simple headers and trailing spaces are actually a bit pitfall. first, space escaping is not a
// Define the EncodingCopy codeThe Code is as follows: header ('content-Type: text/html; charset = UTF-8 ');// AtomCopy codeThe Code is as follows: header ('content-type: application/atom + xml ');// CSSCopy codeThe Code is as follows: header
Both are request-based forwarding. Both are request-based forwarding.
Reply content:
Both are request forwarding.
If I understand it correctly, you are talking about request forwarding and redirection.
There are two essential differences
Instructions for using the header () function:I. role:~~~~~~~~~PHP only sends the HTML document header to the browser using the HTTP protocol to tell the browser how to handle the page. As for the transmitted content, you need to familiarize
In PHP, the use of the header function is very large, the header can not only send the original HTTP header information to the client, but also can directly implement the file download operationThe header function is most commonly used not for
We recommend a table import method that does not require the introduction of a class file in addition to the Phpexcel Export Table--header () export Excel table.
The steps for exporting a table are encapsulated as methods for reuse, with the
For this function is not much in-depth understanding, is usually used to set the character encoding or page jump, set the code will not elaborate.
Previously for the header jump just know jump before any output, otherwise it will be wrong, but
The header function of PHP can be used to implement META tags in HTML code with very little code.
Here only to use the header function to do the page jump
1. Code for page jumps in HTML codeHTML Meta Refresh and jump (redirect) pageRefresh
Summary of HTTP protocol and common methods used by headers in PHP, and Header summary. Summary of the HTTP protocol and common methods used by the Header in PHP. the header summary examples in this article summarize the HTTP protocol and common
This article mainly introduces the definition and usage of the header of PHP headers, the interested friend's reference, hope to be helpful to everyone.
The header () function sends the original HTTP header to the client.
It is important to
Defining the Encoding
AtomCssJavascriptJPEG ImageJsonPdfRssText (Plain)XmlOkSet a 404 Header:Set address to be permanently redirectedGo to a new addressFile Delay Steering:print ' You'll be redirected in ten seconds ';Of course, you can also use
The PHP tutorial header () function is described in detail with an example
Grammar
Header (string,replace,http_response_code) parameter description
string is required. Specifies the string of headers to send.
Replace is optional. Indicates whether
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.