0

At the very end of the redirect function in pset7 in functions.php there was:

//exit immediately since we're redirecting anyway.

exit;

I know that exit prevents from interpreting any code below it but the function is returning anyway. So, why it existed here?

1 Answer 1

0

The function call redirects to the page and then tells PHP to exit.

Consider this scenrario: You're on buy.php and as soon as you buy something, you want to redirect to history.php. When you call the redirect() function with history.php as the argument, the function tells the page to redirect and tells the code on buy.php to exit.

1
  • So you are saying that in this scenario, if you didn't write exit after you are redirected to history.php, the code below redirect() will be interpreted anyway even after you are redirected ???!!! Commented Jun 28, 2014 at 22:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .