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? 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(); 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. 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. 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. 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. 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 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
Archived
This topic is now archived and is closed to further replies.