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. Implement 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 Network ', LOCK_EX); |
If the PHP file runs through a header ("Location: a page URL"), the statement jumps directly to another page, but the jump here does not affect the continuation of the current PHP file. That is to say, after the PHP header jump, the current page of the script will continue to execute. If you need to terminate the script, you need to add exit () or Die ().
But there's no need for some usage.
404 Code
copy code |
tr>
<?php Header ( ' http/1.1 404 Not Found '), Header ("status:404 not Found"); ? 301 <? Header ("http/1.1 301 Moved permanently"); Header ("location: www.111cn.net"); ? |