PHP header after the need to write exit to terminate the program, has not been too concerned about the past, today encountered a bug, just found that this is still a problem, deliberately wrote a paragraph of code test, the code is as follows:
<?php
Header ("location:http://www.alixixi.com/");
Exit ();
File_put_contents ($_server[' document_root '). Directory_separator. " N.txt ", ' PHP Programmer tutorial Web ', LOCK_EX);
The results show that if the PHP file runs with header ("Location: a page URL"), this statement will jump directly to another page, but the jump does not affect the continuation of the current PHP file. 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 ().
Articles that you may be interested in
- PHP get_headers to determine if the URL is valid
- PHP with header () implementation file download, download the file hint is broken can not open the solution
- function and usage of PHP get_headers function
- PHP Analog get_headers function
- Use and difference in PHP to jump out of multiple loops using Break,continue,goto,return,exit
- PHP header 404 Jump error page
- PHP finds whether a value exists in the array (In_array (), Array_search (), array_key_exists ())
- Summary of usage of PHP header