note 2482 deleted from function.register-shutdown-function by jimw

From: Date: Tue, 18 Dec 2001 19:44:20 +0000
Subject: note 2482 deleted from function.register-shutdown-function by jimw
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-23167@lists.php.net to get a copy of this message
PHP 3: Whenever using register_shutdown...() and having the need to use exit;, I make another function, nice_exit() that calls whatever shutdown function was registered and then doing a hard exit: <pre> function my_shutdown() { // Whatever cleanup routines, DB, logging, etc. } function nice_exit() { // Call the register shutdown function my_shutdown(); // Hard Exit exit; } register_shutdown_function("my_shutdown"); </pre> and in normal code, I use nice_exit() in place of exit; <pre> // code to execute if ($some_condition) { nice_exit(); } // code that might not execute </pre>

« previous php.notes (#23167) next »