IMPRESS dotted_line CONTACT dotted_line search dotted_line Kontakt dotted_line sitemap dotted_line print
114 PHP-Resource users online

Switch to another languags Deutsch aktuelle Sprache Englisch

PHP Manual


(PHP 4, PHP 5)

register_shutdown_functionRegister a function for execution on shutdown


void register_shutdown_function ( callable $callback [, mixed $parameter [, mixed $... ]] )

Registers a callback to be executed after script execution finishes or exit() is called.

Multiple calls to register_shutdown_function() can be made, and each will be called in the same order as they were registered. If you call exit() within one registered shutdown function, processing will stop completely and no other registered shutdown functions will be called.



The 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.


It is possible to pass parameters to the shutdown function by passing additional parameters.


Return Values

No value is returned.


If the passed callback is not callable a E_WARNING level error will be generated.


Version Description
4.1.0 The shutdown functions are now called as a part of the request. In earlier versions under Apache, the registered shutdown functions were called after the request has been completed (including sending any output buffers), so it was not possible to send output to the browser using echo or print, or retrieve the contents of any output buffers using ob_get_contents(). Headers were also always already sent.


Example #1 register_shutdown_function() example

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;




Working directory of the script can change inside the shutdown function under some web servers, e.g. Apache.

See Also

Comments to the PHP manual
Write new comment


New Tutorial entries

Migration einer PHP 5 App auf PHP 7

Dieses PHP 7 Tutorial zeigt dir, wie du dein PHP5 Script auf PHP7 umstellst.

Berni | Category: PHP
PHP 7 Virtual Machine

Dieser Artikel zielt darauf ab, einen Überblick über die Zend Virtual Machine, wie es in PHP 7 gefunden wird.

Berni | Category: PHP
plotting masters - a professional guide - Teil II

Grafische Interpolation und Bestapproximation von numerischen Wertepaaren: Wir wollen Punkte auf einer Zeichenebene über verschiedene Verfahren miteinander verbinden.

EVAMasters | Category: PHP