http - PHP: Effect of code after header("Location: abc.html") -


lets say, code looks this:

if(!$test) {   header("location: somefile.html");   ...some php code....   header("location: anotherfile.html"); } 

is 'some php code' above executed? if yes, happens further http response(s) therein (eg.: second 'header' statement in code)?

yes - code executed.

the header() configure headers returned, not send them right away.

  • if there no output between 2 calls, last one taken account.

  • however, if output anything before second call, headers sent, , second call result in error (headers sent).

a classic mistake : redirect , not exit() right after that, can cause security problems.


Comments