|
Posted by Rik Wasmus on 11/06/07 17:18
On Tue, 06 Nov 2007 13:44:14 +0100, Michael Fesser <netizen@gmx.de> wrote:
> .oO(Rik Wasmus)
>
>> On a header redirect, the user effectively 'aborts' as soon as he got
>> it.
>
> A header() call doesn't sent the header out immediately. This would make
> the second parameter pretty useless and would also let headers_sent()
> return TRUE after the first header() call, which is not the case.
>
> Even on a redirection header the script continues to run until it
> reaches the end or an exit() call, so IMHO the OP's script should work
> as expected.
Well, that's sort of true. As soon as you do something which sends the
headers (normal output for instance) the user can abort the connection
(well, the user can abort at any time, it's just more likely it happens,
as most redirects should be without content). In this particular case it
will almost always work as expected due to the fact there's no output and
it's a tiny script which runs it course way before the HTTP connection is
aborted. On more complex scripts, which cause the user to be redirected
(or the user is fed up with your slow site and navigates away/closes the
connection), the default is the script will terminate as soon as it
realises that there's no user to give the output to anymore. See
<http://nl2.php.net/manual/en/features.connection-handling.php>. That's
where the very usefull function ignore_user_abort() (it's critical the
script runs it course, even without anyone to give output to) and/or
register_shutdown_function() (some things really should be cleaned up)
come into play.
For the OP it's quite academic really, under normal circumstances it will
run just fine either way around.
--
Rik Wasmus
Navigation:
[Reply to this message]
|