[thelist] PHP Header oddness
Steve Lewis
nepolon at worlddomination.net
Fri Oct 7 10:07:34 CDT 2005
Mark Groen wrote:
> It's not really a bug afaik, as *any* error or undefined variable counts
> as output. Not exactly sure which will work in your case, finessing
> header('WWW-Authenticate: Negotiate') [http://ca.php.net/header] would
> probably work, using ob_start() and ob_end_flush() in your script will
> work for sure.
>
> Also check for blank space before and after the <?php ?> of course,
> we've all missed that one. About the third note down on the docs there's
> more info about the odd things header("Location: do that may help.
I suppose I wasn't too clear about this detail, but I have a workaround.
The workaround looks like adding the following function to the library:
function forward_to($url)
{
header("Location: ".$url);
}
and changing the if/else to
if($retval) {
$session->set('useredit', true);
forward_to($session->get(Session::REFERRER));
}
/* Error found with form */
else {
$session->set('last_form', $form);
forward_to($session->get(Session::REFERRER));
}
The "bug" appears to be that between the if clause and the else clause,
the parser sees two header calls, and balks at the second, even though
it cannot execute both. When the call to header() is replaced by the
function above, centralizing the call, the warning goes away. It seems
incredibly odd, but the workaround could be masking some other issue.
There are no blank spaces before the <?php directive, or I would have an
Error instead of a Warning. The $retval variable is always set to
either true or false.
--
SteveL
More information about the thelist
mailing list