note 100859 deleted from function.register-shutdown-function by crell
| From: | crell@php.net | Date: | Wed, 30 Mar 2022 22:06:38 +0000 |
| Subject: | note 100859 deleted from function.register-shutdown-function by crell | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-217811@lists.php.net to get a copy of this message | ||
Note Submitter: david dot schueler at tel-billig dot de
----
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)