[Guide] in the PHP language, the header () function is useful, especially when using Ajax. Here are some detailed explanations of the header.
In the PHP language, the header () function is useful, especially when using Ajax.
Here are some detailed
Header ("http/1.1 404 Not Found");
Copy CodeFor the ErrorDocument 404/404.php function in Apache configuration, the
Error_page 404/404.php;
Copy CodeChange into
Error_page 404
Header ("location:http://www.php.net";);
Exit After each redirect, "Exit" must be added to avoid an error and continue execution.
?>
Header ("refresh:3;url=http://bbs.it-home.org");
Print (' Loading, please wait .
If you encounter problems in a project, when a user successfully logs on to the homepage with the header, it is always wrong and cannot jump to the page you want. It took a long time for du Niang to find a solution. I will share it with you here.
Syntax:
Send the original to the client
Be aware that:
Header
Parameter description:
parameters
description
string
required. Specifies the string of headers to send.
The cache of the Web page is controlled by the "Cache-control" in the HTTP message header, and the common values are private, No-cache,-age, must-1-cache, must---control:-age=52---3-revalidate,--4The-control value is "no-: Fri, 1999 16:00:00= no-=no-
Experiments show that the fread function can read a maximum of 8192 bytes at a time, that is, 8 kB. If you want to read a file larger than this size, you need to read it cyclically until the end of the file. Based on the above corrections, the
Now that I am older, my sense of smell in the face of problems is no longer sensitive. I feel that nothing is correct. I wonder if I forget to quit after redirection, and there is content output later, however, I checked the code and found that
Usually, when judging a non-existing resource (such as category or product does not exist) through php, you need to return a 404 status through the header and display the corresponding 404 page. The method on the previous server is as follows: The
The header () function uses the description:
first, the role:~~~~~~~~~
PHP only in the HTTP protocol to the HTML document header to the browser, tell the browser how to deal with this page, as for the content of the transfer will need to
1 Force refresh View with header: Add at the beginning of the pagePHP Header ("Expires:mon, Jul 1997 05:00:00 GMT"); Header ("Cache-control:no-cache"); Header ("Pragma:no-cache");? >2 Jump to error page, print out error message: When the value is
In php, the header function is used heavily. the header can not only send the original HTTP header information to the client, but also directly implement File Download operations, next we will introduce you to the editor.
The header function is most
{Code...}: If the admin parameter is not added after the domain name, the domain name can be redirected normally! It will be redirected to the homepage of the website. I want it to be redirected to the background login page, so the admin parameter
For the ErrorDocument 404/404. php function in apache configuration The code is as follows:Copy code Error_page 404/404 .php; Change The code is as follows:Copy code Error_page 404 =/404.php; PhpThe page cannot be found because the header
In the manual, we write how to set the cache so that the code is not cached: The code is as follows:Copy code Header ("Cache-Control: no-store, no-cache, must-revalidate, post-check = 0, pre-check = 0"); // HTTP/1.1Header ("Expires: Sat, 26 Jul 1
Header (string, replace, http_response_code)String is required. Specifies the header string to be sent.Replace is optional. Indicates whether the header replaces the previous header or adds the second header.The default value is true (replace ).
In HTTP transmission text, the required header and content order must be: header is after the previous content, and header must be formatted with the format "keyword:value\n".
1, the header output before the output, it will cause the header of the
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.