note 95995 added to functions.anonymous
| From: | bishamon at osu1 dot php dot net | Date: | Tue, 02 Feb 2010 04:02:38 +0000 |
| Subject: | note 95995 added to functions.anonymous | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-165585@lists.php.net to get a copy of this message | ||
In response to (kwilson at shuttlebox dot net):
The global keyword always pulls from the global scope. In your test() function, $variable is in
test()'s local scope. When the function in $closure is called, the global statement goes out to
the global scope to find $variable.
This is just normal PHP variable scope behavior. It has nothing to do with anonymous functions or
closures (which are two separate, but related concepts).
----
Server IP: 208.69.120.55
Probable Submitter: 65.190.53.32
----
Manual Page -- http://www.php.net/manual/en/functions.anonymous.php
Edit -- https://master.php.net/note/edit/95995
Del: integrated -- https://master.php.net/note/delete/95995/integrated
Del: useless -- https://master.php.net/note/delete/95995/useless
Del: bad code -- https://master.php.net/note/delete/95995/bad+code
Del: spam -- https://master.php.net/note/delete/95995/spam
Del: non-english -- https://master.php.net/note/delete/95995/non-english
Del: in docs -- https://master.php.net/note/delete/95995/in+docs
Del: other reasons-- https://master.php.net/note/delete/95995
Reject -- https://master.php.net/note/reject/95995
Search -- https://master.php.net/manage/user-notes.php