note 100859 added to function.register-shutdown-function

From: Date: Thu, 11 Nov 2010 12:51:36 +0000
Subject: note 100859 added to function.register-shutdown-function
Groups: php.notes 
Request: Send a blank email to php-notes+get-173940@lists.php.net to get a copy of this message
I had a problem when forking a child process and accessing the variables by using the "global" keyword in the shutdown function. So i used another way for getting the variables to the shutdown function: I passed them by reference. Example: <?php function shutdown_function (&$test) { echo __FUNCTION__.'(): $test = '.$test."\n"; } $test = 1; register_shutdown_function('shutdown_function', &$test); echo '$test = '.$test."\n"; // do some stuff and change the variable values $test = 2; // now the shutdown function gets called exit(0); ?> Maybe tis helps someone. (I'm using PHP 5.2.11) ---- Server IP: 217.160.235.204 Probable Submitter: 84.184.50.199 ---- Manual Page -- http://www.php.net/manual/en/function.register-shutdown-function.php Edit -- https://master.php.net/note/edit/100859 Del: integrated -- https://master.php.net/note/delete/100859/integrated Del: useless -- https://master.php.net/note/delete/100859/useless Del: bad code -- https://master.php.net/note/delete/100859/bad+code Del: spam -- https://master.php.net/note/delete/100859/spam Del: non-english -- https://master.php.net/note/delete/100859/non-english Del: in docs -- https://master.php.net/note/delete/100859/in+docs Del: other reasons-- https://master.php.net/note/delete/100859 Reject -- https://master.php.net/note/reject/100859 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#173940) next »