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 yourself with the HTTP protocol, PHP is irrelevant. in php, the header
Usage of the PHPheader () function (incorrect settings such as 301 and 404)
Header ("HTTP/1.1 404 Not Found ");
For the ErrorDocument 404/404. php function in apache configuration
Error_page 404/404
Example of phpheader function usage (1)
Print ""; // The cache file is normally read.
?>
Print ""; // adds a unique number to make the browser request again
W // print "";
?>
Example of setting various HTTP headers using the header function in php
/**
Desc: header function to set various HTTP headers
Link: bbs.it-home.org
Date:
*/
// Define the encoding
Summary of common methods for PHPheader () functions. Definition code copy code: header (Content-Type: texthtml; charsetutf-8); Atom copy code: header (Content-type: applicationatom + xml ); CSS copy // define the encoding
The code is as
The phpheader function is commonly used for http header settings. Common http header settings for the phpheader function, and the okheader ('http1. required OK); set a 404 header: header ('http1. 1404 NotFound); set the address to be permanently
This article mainly introduces common methods of PHPheader () functions and summarizes common usage. For more information, see // coding.
The code is as follows: header ('content-Type: text/html; charset = utf-8 ');
// Atom
The code is as
Building a simple interactive website (iii)
6. Password verification
Maybe you want to put your photo collection on your website, and just want to show your intimate friends that you need a password verification program.
6.1 HTTP-based
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, Max-age, must-revalidate, etc., and the default is private. Its function is divided into the following situations
Header (' http/1.1 OK '); OK normal access
Header (' http/1.1 404 Not Found '); Notifies the browser that the page does not exist
Header (' http/1.1 301 Moved permanently '); Set the address to be permanently redirected 301
Header ('
Building a simple interactive website ( three )
6. Password verification
Maybe you want to put your photo collection on your website, and just want to show your intimate friends that you need a password verification program.
Building a simple interaction website (3)
6. Password Verification
Maybe you want to put your photo set on your website, and you just want to show it to your friends. At this time, you need a password for verification.Program.
6.1 HTTP-based
In PHP 301 REDIRECT implementation is very simple, we simply use the header to send 301 status code, and then use header to jump, the effect and Apache,iis,nginx are the same effect oh.
One: This method is more recommended because it can transfer
Building a simple interactive website (iii)
6. Password verification
Maybe you want to put your photo album on your website and just want to show your intimate friends that you need a password verification program.
6.1 Based on HTTP
Transferred from PHP Chinese user 5. Other miscellaneous
5.1 Generating Images
PHP can manipulate image processing. If you have installed the GD library, you can even use PHP to generate images.
?
Header ("Content-type:image/gif");
$string =implode
Comparison of HTTP 1.1 and HTTP 1.0
http://blog.csdn.net/weizhaozhe/article/details/3958945
A Web site may receive millions of user requests a day, in order to improve the efficiency of the system, HTTP 1.0 requires the browser and the server to
HTTP 1.1 compared to HTTP 1.0
A Web site may receive millions of user requests a day, in order to improve the efficiency of the system, HTTP 1.0 requires the browser and the server to maintain only a brief connection, every time the browser needs
5. Other Miscellaneous
5.1 Generating Images
PHP can manipulate image processing. If you have installed the GD library, you can even use PHP to generate images.
?
Header ("Content-type:image/gif");
$string =implode ($ARGV, "");
$im =
Header function and Php_auth_user do user authentication 2009-12-16 01:32
php Header php_auth_user PHP_AUTH_PW user authentication
In PHP, you can use the header function to do some interesting things, and user authentication is one of the most
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.