RE: [PHP] header & headers_sent BUG
| From: | Ford, Mike [LSS] | Date: | Wed, 23 Jul 2003 11:07:31 +0000 |
| Subject: | RE: [PHP] header & headers_sent BUG | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-156430@lists.php.net to get a copy of this message | ||
> -----Original Message-----
> From: James M. Luedke [mailto:james@dod.net]
> Sent: 22 July 2003 07:07
> I am having a hard time with a small piece of code. I was
> wondering
> if someone may be able to explain why the following code will
> not work... I
> have been scratching my head for a few hours now and I am stumped.
>
> <?php
>
> header("Location: http://someplace.com");
At this point, you have specified that you want the header "Location: http://someplace.com" to be sent when headers are sent --
but headers are not sent until you output some actual content to your page. So...
> if( ! headers_sent())
... headers haven't been sent yet, so this test always triggers, so...
> header("Location: http://somplaceelse.com");
... this call always executes, specifying that, actually, you want *this* Location header to be sent
when headers are sent, not the one specified before.
I haven't the faintest idea what you might be trying to achieve here, but I think you need to
rethink the logic of how you choose which redirect to use.
Cheers!
Mike
---------------------------------------------------------------------
Mike Ford, Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS, LS6 3QS, United Kingdom
Email: m.ford@lmu.ac.uk
Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211