Re: Using 'header' as redirect

From: Date: Tue, 30 May 2006 17:10:03 +0000
Subject: Re: Using 'header' as redirect
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-237096@lists.php.net to get a copy of this message
Ok, I have modified my code a little bit. Stut, yes, output buffering was on by default (4096). I *think* this will work. It appears to be the same as before - still redirecting appropriately: <!-- index.php --> <? ob_start(); ?> <html> <head>...</head> <body> <? include ($subPage); ob_end_flush(); ?> </body> The subpage does not change any, only index.php. I am basically "holding off" on displaying the stuff between ob_start() and ob_end_flush(), unless it's header information. That way, if the subpage needs to redirect, it can without errors. Correct? Thanks to all for your help! ~Philip On May 30, 2006, at 11:37 AM, Stut wrote:
Philip Thompson wrote:
As you can see, by the time that index.php includes the subpage, it has already outputted HTML. According to using the header() function, you are not allowed to output any HTML *before* using header(). However, I am doing this and it is redirecting fine. I have hypothesized why it is still redirecting appropriately... *subpage.php* has not outputted HTML before it does the check, only index.php, so it does not fail. Is this correct? Any help is appreciated. It appears to work fine, but I don't want to be surprised in the future by my application breaking suddenly!! =D
Check phpinfo and see if you have output buffering on by default. If you do, that's why and you shouldn't rely on it being that way. -Stut


« previous php.general (#237096) next »