Re: redirect

From: Date: Mon, 24 Jul 2000 20:39:32 +0000
Subject: Re: redirect
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-7966@lists.php.net to get a copy of this message
> > So how can you redirect from a place deep in the code? > > The trick, generally, is not to have to. I dare say that if you have to > redirect deep in code, you're likely doing something wrong. Exactly. Except perhaps not "wrong", just different. <? // lots of code, produce a result // want to print a result? stick it in a variable and echo it later // want to redirect? go ahead - you haven't printed anything yet ?> <html> .... <? echo "$thatvartoprint"; ?> .... </html> If you get as far as <html>, it's because you have something to print. If not, then you're free to header("Location..."); away. +------------------------------------------------+ | Julie Meloni (jcm@i2ii.com) | | Tech. Director, i2i Interactive (www.i2ii.com) | | | | "PHP Essentials" & "PHP Fast & Easy" | | http://www.thickbook.com/ | +------------------------------------------------+

« previous php.general (#7966) next »