[thelist] PHP Header oddness

Steve Lewis nepolon at worlddomination.net
Fri Oct 7 08:19:19 CDT 2005


I find that when I turn off output_buffering, something strange happens.
I call it a bug.  I have a workaround, but I am curious, has anyone else
seen this issue and I am curious what you have done about it.

     if($retval) {
         $session->set('useredit', true);
         header("Location: ".$session->get(Session::REFERRER));
     }
     /* Error found with form */
     else {
         $session->set('last_form', $form);
         header("Location: ".$session->get(Session::REFERRER));
     }

Even though it is impossible to execute both header() statements, the
PHP parser sees the first one and considers the request irrevocably
modified, right then and there.  When the second line is parsed, it's an
error.  It's actually a warning, but a fatal-sounding one:

Warning: Cannot modify header information - headers already sent by
(output started at
/[...]/phproot/process.php:225) in
/[...]/phproot/process.php on line 233


-- 
SteveL



More information about the thelist mailing list