$_SESSION["some_value"] = 4; header("Location: another-file.php"); $_SESSION["some_value"] = 5;
what's the value of $_SESSION["some_value"]
?
exit() terminates the current script. My basic understanding of it is that the header function doesn't immediately terminate the connection and the code after can still be executed. So adding exit after header is to make sure that code after it won't be executed.
You definitely should. Otherwise the script execution is not terminated. Setting another header alone is not enough to redirect. exit always interrupts the current script (in your case "fileA").
The value is 5.
You can output a lot more headers than just Location
headers with header
, most of which you don't want to stop your code execution. If you want to stop code execution, you need to call exit
explicitly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With