register_shutdown_function()
| From: | Oriol de San Pedro | Date: | Wed, 27 Dec 2000 18:01:58 +0000 |
| Subject: | register_shutdown_function() | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-42326@lists.php.net to get a copy of this message | ||
> They are most likely going to make whatever function you register for
> shutdown ABLE to output to the browser. So then you have the same results
> in the CGI and the SAPI versions, you see what you print.(contrary to the
> documentation)
>
> As for the sleep(), it will wait so it probably shouldn't be used in that
> context.
I think that would be a mistake!!... If the CGI version can't handle it,
it's OK, but for the module version this can be very useful for some
operations.
Real world example:
- Tracking outgoing links from your site:
Instead of linking to http://www.yahoo.com , you link to an
intermediary
go-yahoo.php, the php would header("Location: http://www.yahoo.com"); and
register a shutdown function. When the "normal" php lifetime ends the
header/response is actually sent to client, without waiting any further.
Then, after the client is on its way to yahoo the shutdown funtion has ample
time to deal with registering the event on the database, something that
could potentially last too much time for the client to wait for...
If you change that behavior the redirect would only take place after
finishing access to database. So redirection gets much slower.
Speed in general isn't all that important, but for an outgoing link speed is
critical!
Please don't change that behavior!
Thank you.
Oriol