Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
Thread: Should I Exit?
05-13-2014, 04:34 AM #1
Should I Exit?
Should I add an exit() statement to each of my case statements?
// Determine Sort-Type.
header("Location: " . BASE_URL . "/some_path");
05-13-2014, 09:34 AM #2
- Join Date
- Sep 2011
- Thanked 27 Times in 27 Posts
Short answer: Between
It depends on the rest of the code and what exactly you want it to do. If you want it to simply stop what it's doing and redirect to that location, add
break;. If you want other stuff to happen after the switch then don't do anything. If the switch is the last thing to happen, you don't need it to use exit() because it will end after that anyways.
05-13-2014, 10:54 AM #3
- Join Date
- Jan 2010
- Behind the Wall
- Thanked 375 Times in 371 Posts
additional note: if each of your cases does a redirect, you may also call exit() after the switch().
The computer is always right. The computer is always right. The computer is always right. Take it from someone who has programmed for over ten years: not once has the computational mechanism of the machine malfunctioned.André Behrens, NY Times Software Developer
05-13-2014, 04:07 PM #4