note 95778 deleted from functions.anonymous by cmb

From: Date: Sun, 11 Aug 2019 10:55:24 +0000
Subject: note 95778 deleted from functions.anonymous by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-211838@lists.php.net to get a copy of this message
Note Submitter: kwilson at shuttlebox dot net ---- Using the global keyword apparently pulls variables from the scope where the function was created, not where it is executed. Example: <?php $variable = "first"; $closure = function() { global $variable; echo $variable . "\n"; }; $closure(); function test($closure) { $variable = "second"; $closure(); } test($closure); ?> Will print: first first

« previous php.notes (#211838) next »