Hi I have this function
function fail($pub, $pvt = '')
{
global $debug;
$msg = $pub;
if ($debug && $pvt !== '')
$msg .= ": $pvt";
$_SESSION['msg'] = $msg;
header ("Location: /voting/");
exit;
}
The page should redirect before it gets to the exit command right? Without the exit command however the function doesn’t work correctly (it continues on even though it should have redirected). If anyones knows could you explain why the code continues on if the function did not exit even though in both cases it will redirect?
The browser won’t redirect until it receives the whole response after the script ends, and the PHP script certainly doesn’t stop when the browser redirects, so ending the script when the browser is supposed to redirect is the best course of action.