register_shutdown_function
register_shutdown_function
Register a function for execution on shutdown
void **register_shutdown_function** callable $callback mixed $args
Registers a to be executed after script
execution finishes or is called.
callback``exit
Multiple calls to can be
made, and each will be called in the same order as they were registered.
If you call within one registered shutdown
function, processing will stop completely and no other registered
shutdown functions will be called.
register_shutdown_function``exit
Shutdown functions may also call
themselves to add a shutdown function to the end of the queue.
register_shutdown_function
callbackThe shutdown callback to register.
The shutdown callbacks are executed as the part of the request, so it's possible to send output from them and access output buffers.
argsIt is possible to pass parameters to the shutdown function by passing
additional parameters.
return.void
Voorbeeld: example
<?php
function shutdown()
{
// This is our shutdown function, in
// here we can do any last operations
// before the script is complete.
echo 'Script executed with success', PHP_EOL;
}
register_shutdown_function('shutdown');
?>
Opmerking: > The working directory of the script can change inside the shutdown function under some web servers, e.g. Apache.
Opmerking: > Shutdown functions will not be executed if the process is killed with a SIGTERM or SIGKILL signal. While you cannot intercept a SIGKILL, you can use to install a handler for a SIGTERM which uses to end cleanly.
pcntl_signal``exit
Opmerking: > Shutdown functions run separately from the time tracked by . That means even if a process is terminated for running too long, shutdown functions will still be called. Additionally, if the runs out while a shutdown function is running it will not be terminated. max_execution_time
max_execution_time
auto_append_fileexit``fastcgi_finish_requestconnection handling