How to stop function code after header("location: $url")

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
lwc
Forum Commoner
Posts: 35
Joined: Thu Jan 11, 2007 11:04 am

How to stop function code after header("location: $url")

Post by lwc »

The documentation for "header" says to use "exit" after "header".

Should I use "return" instead of "exit" when header("location: $url") is ran from inside a function? The documentation doesn't relate to such a scenario.

Thanks!
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: How to stop function code after header("location: $url")

Post by VladSun »

Use exit().
A return() called in a function doesn't guarantee that the code execution will stop immediately after the function call.
There are 10 types of people in this world, those who understand binary and those who don't
Post Reply