note 23370 deleted from function.register-shutdown-function by googleguy

From: Date: Tue, 22 Oct 2013 09:03:18 +0000
Subject: note 23370 deleted from function.register-shutdown-function by googleguy
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-196861@lists.php.net to get a copy of this message
Note Submitter: enygma at phpdeveloper dot org ---- I figured I'd share this since I got it working on my box.... this lets you run the "bye" function if the page ends normally or they stop it. <?php set_time_limit("0"); function bye(){ //this is run when the page ends if(connection_aborted()){ //this just means that the user hit the stop button or something } } register_shutdown_function('bye'); $count=100000000000000; for($i=0; $i<$count; $i++){ #sit here and loop for a bit so we can have time to hit Stop... echo " \n"; } echo "end"; ?> I figured it might be useful to someone out there trying to run a function when the page ends (or is stopped).

« previous php.notes (#196861) next »