note 105385 added to functions.anonymous
| From: | ldrut at osu1 dot php dot net | Date: | Sat, 13 Aug 2011 20:24:35 +0000 |
| Subject: | note 105385 added to functions.anonymous | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-182469@lists.php.net to get a copy of this message | ||
A common way to avoid contaminating Javascript global space with unneeded variables is to move the
code into an immediately called anonymous closure.
(function(){ ... })()
The equivalent way to do that in PHP 5.3+ is
call_user_func(function() use(closure-vars){ ... });
----
Server IP: 69.147.83.197
Probable Submitter: 99.97.49.31
----
Manual Page -- http://www.php.net/manual/en/functions.anonymous.php
Edit -- https://master.php.net/note/edit/105385
Del: integrated -- https://master.php.net/note/delete/105385/integrated
Del: useless -- https://master.php.net/note/delete/105385/useless
Del: bad code -- https://master.php.net/note/delete/105385/bad+code
Del: spam -- https://master.php.net/note/delete/105385/spam
Del: non-english -- https://master.php.net/note/delete/105385/non-english
Del: in docs -- https://master.php.net/note/delete/105385/in+docs
Del: other reasons-- https://master.php.net/note/delete/105385
Reject -- https://master.php.net/note/reject/105385
Search -- https://master.php.net/manage/user-notes.php