Why the Location header does not redirect the page immediately?
It always performs the entire process before redirecting?
I will give some example:
header('Location:http://www.php.net');
$f = fopen('demo.txt','w+');
fwrite($f,'Test');
fclose($f);
It always generates the TXT file before redirecting to http://www.php.net.
Well,
header()just sends certain header to browser. PHP still continues running the script after that. If you don’t want to stop running the script, just usedie;orexit;– it will stop processing the script further.