I’ve got an a simple include for my new project.
What happens is my included file checks a few functions and outputs the results.
If there is any kind of error I want a simple redirect to happen.
The problem I’m having is that the rest of the main file (which has the include on) keeps loading for a few seconds, before the redirect can be complete.
Is there possibly a way of sleeping the main file while the checks are made?
Thanks!
EDIT @dan:
Part of the included file:
function redirect($url) {
if(!headers_sent()) {
header('Location: '.$url);
exit;
} else {
echo '<script type="text/javascript">';
echo 'window.location.href="'.$url.'";';
echo '</script>';
echo '<noscript>';
echo '<meta http-equiv="refresh" content="0;url='.$url.'" />';
echo '</noscript>';
exit;
}
}
$url = "http://www.whatever.com/";
redirect($url);
exit;
Use
dieorexitto stop execution when you get to the point you want to redirect.