There are usually three kinds:
| The code is as follows |
Copy Code |
Location:xxxx:yyyy/zzzz Content-type:xxxx/yyyy status:nnn xxxxxx |
Common examples
1. Implementation redirection (Status Code 302)
| The code is as follows |
Copy Code |
<?php Header ("Location:http://www.111cn.net"); Exit ?> |
Example
| The code is as follows |
Copy Code |
<?php Header ("location:http://www.111cn.net/"); Exit (); File_put_contents ($_server[' document_root '). Directory_separator. " N.txt ", ' PHP Programmer tutorial Web ', LOCK_EX); |
The results show that PHP files run if you encounter a header ("Location: a page URL"), this statement will jump directly to another page, but the jump here does not affect the current PHP file to continue execution. That is, after the PHP header jumps, the script for the current page continues to execute. If you need to terminate the script operation, you need to add exit () or Die ().
But there's no need for some use.
404 Code
| The code is as follows |
Copy Code |
<?php Header (' http/1.1 404 Not Found '); Header ("status:404 not Found"); ?> 301 ? Header ("http/1.1 moved Permanently"); Header ("Location:www.111cn.net"); ?> |