note 117427 added to class.closure
| From: | chuck at bajax dot us | Date: | Tue, 09 Jun 2015 16:16:48 +0000 |
| Subject: | note 117427 added to class.closure | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-202787@lists.php.net to get a copy of this message | ||
This caused me some confusion a while back when I was still learning what closures were and how to
use them, but what is referred to as a closure in PHP isn't the same thing as what they call
closures in other languages (E.G. JavaScript).
In JavaScript, a closure can be thought of as a scope, when you define a function, it silently
inherits the scope it's defined in, which is called its closure, and it retains that no matter
where it's used. It's possible for multiple functions to share the same closure, and they
can have access to multiple closures as long as they are within their accessible scope.
In PHP, a closure is a callable class, to which you've bound your parameters manually.
It's a slight distinction but one I feel bears mentioning.
----
Server IP: 72.52.91.14
Probable Submitter: 104.171.243.82
----
Manual Page -- http://php.net/manual/en/class.closure.php
Edit -- https://master.php.net/note/edit/117427
Del: integrated -- https://master.php.net/note/delete/117427/integrated
Del: useless -- https://master.php.net/note/delete/117427/useless
Del: bad code -- https://master.php.net/note/delete/117427/bad+code
Del: spam -- https://master.php.net/note/delete/117427/spam
Del: non-english -- https://master.php.net/note/delete/117427/non-english
Del: in docs -- https://master.php.net/note/delete/117427/in+docs
Del: other reasons-- https://master.php.net/note/delete/117427
Reject -- https://master.php.net/note/reject/117427
Search -- https://master.php.net/manage/user-notes.php