note 117469 added to class.closure

From: Date: Sun, 14 Jun 2015 17:42:55 +0000
Subject: note 117469 added to class.closure
Groups: php.notes 
Request: Send a blank email to php-notes+get-202861@lists.php.net to get a copy of this message
Scope A closure encapsulates its scope, meaning that it has no access to the scope in which it is defined or executed. It is, however, possible to inherit variables from the parent scope (where the closure is defined) into the closure with the use keyword: function createGreeter($who) { return function() use ($who) { echo "Hello $who"; }; } $greeter = createGreeter("World"); $greeter(); // Hello World This inherits the variables by-value, that is, a copy is made available inside the closure using its original name. font: Zend Certification Study Guide. ---- Server IP: 72.52.91.14 Probable Submitter: 177.152.186.90 ---- Manual Page -- http://php.net/manual/en/class.closure.php Edit -- https://master.php.net/note/edit/117469 Del: integrated -- https://master.php.net/note/delete/117469/integrated Del: useless -- https://master.php.net/note/delete/117469/useless Del: bad code -- https://master.php.net/note/delete/117469/bad+code Del: spam -- https://master.php.net/note/delete/117469/spam Del: non-english -- https://master.php.net/note/delete/117469/non-english Del: in docs -- https://master.php.net/note/delete/117469/in+docs Del: other reasons-- https://master.php.net/note/delete/117469 Reject -- https://master.php.net/note/reject/117469 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#202861) next »