LooieENG Posted May 11, 2008 Share Posted May 11, 2008 After I do header('location: somewhere.php') do I need to exit, or will the code after not be read anyway? Quote Link to comment https://forums.phpfreaks.com/topic/105154-solved-do-i-need-to-exit-after-headerlocation/ Share on other sites More sharing options...
joecooper Posted May 11, 2008 Share Posted May 11, 2008 i dont think you do, but i had problems using that for some reason. and so i used this instead: $link_update ="index.php"; echo "<script language=\"javascript\">"; echo "location.href = \"$link_update\""; echo "</script>"; exit(); Quote Link to comment https://forums.phpfreaks.com/topic/105154-solved-do-i-need-to-exit-after-headerlocation/#findComment-538366 Share on other sites More sharing options...
LooieENG Posted May 11, 2008 Author Share Posted May 11, 2008 I don't have an actual problem with it, it works, but I was just wondering if I needed to exit after. Quote Link to comment https://forums.phpfreaks.com/topic/105154-solved-do-i-need-to-exit-after-headerlocation/#findComment-538368 Share on other sites More sharing options...
joecooper Posted May 11, 2008 Share Posted May 11, 2008 well it stops the script from being parsed by the server. usually the would redirect be at the end of the code anyway. but its a good idea to have it. Quote Link to comment https://forums.phpfreaks.com/topic/105154-solved-do-i-need-to-exit-after-headerlocation/#findComment-538373 Share on other sites More sharing options...
LooieENG Posted May 11, 2008 Author Share Posted May 11, 2008 Ah, I'll use exit after then, can't do any harm. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/105154-solved-do-i-need-to-exit-after-headerlocation/#findComment-538387 Share on other sites More sharing options...
MadTechie Posted May 11, 2008 Share Posted May 11, 2008 The reason is because the header will fail if their any ouput before it, think of it this way, if you get an error (thats output) thus the header rediect will fail.. so the exit will stop the code, without the exit, the code would continue. Quote Link to comment https://forums.phpfreaks.com/topic/105154-solved-do-i-need-to-exit-after-headerlocation/#findComment-538390 Share on other sites More sharing options...
LooieENG Posted May 11, 2008 Author Share Posted May 11, 2008 Ah, got it. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/105154-solved-do-i-need-to-exit-after-headerlocation/#findComment-538393 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.