Re: PHP Redirect in the middle of code?

From: Date: Mon, 10 Sep 2001 17:10:46 +0000
Subject: Re: PHP Redirect in the middle of code?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-66782@lists.php.net to get a copy of this message
On Tue, 11 Sep 2001, Jason Brooke wrote: > > Right off the top of my head, you have three options that I can see: > > > > (1) Rewrite the code to avoid any output before the redirect. > > I'd recommend this one myself Me too, I can't think of a valid reason to use a Location header while having output also as the user will only have about .00000002 seconds to read the output before being redirected. if ($foo == 'example') { // I'm not output header('Location: http://www.example.com/'); exit; } is perfectly valid. Now, why would someone need to do : if ($foo == 'example') { echo 'Hope you find example.com pleasing, have fun!'; header('Location: http://www.example.com/'); exit; } If such an announcement is needed, using html Meta Refresh tag works as one can also implement the delay (some of our users are slow readers :). Also, headers_sent() can be useful. I'd personally avoid output buffering for this. Regards, Philip Olson > > jason > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.general (#66782) next »