Can I please get some opinions on using the php exit()
function and whether or not it should be avoided completely or some circumstances where it is ok
It should be used where and when appropriate.
MUST USE CASE: After a header redirect
WHY? Php will continue to run the rest of the code following the redirect if you do not use exit/die after the header call.
1 Like
Just like @benanamen had said. Use it whenever it’s appropriate. I tend to use die
instead of exit
simply because die
is shorter to type and does exactly what exit
does. Way less typing and since these “features” aren’t really functions, you don’t necessarily need to use parentheses unless you want to send out a message. So die;
is way shorter and faster to type than exit;
.
3 Likes
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.