note 2482 modified in register_shutdown_function by ronabop

From: Date: Mon, 11 Sep 2000 03:04:51 +0000
Subject: note 2482 modified in register_shutdown_function by ronabop
Groups: php.notes 
Request: Send a blank email to php-notes+get-4689@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> http://www.php.net/manual/function.register-shutdown-function.php

« previous php.notes (#4689) next »