note 89873 added to functions.anonymous

From: Date: Thu, 26 Mar 2009 18:34:12 +0000
Subject: note 89873 added to functions.anonymous
Groups: php.notes 
Request: Send a blank email to php-notes+get-152485@lists.php.net to get a copy of this message
So are these actual closures, or just anonymous functions? That is, can they access/bind to variables in the scope the function is defined in? e.g. $field = 'name'; usort($array, function($a, $b) { return $a->$name > $b->$name; }); or even: $count = 0; array_walk($tree, function($e) { if (check_if_good($e)) ++$count; }); echo $count; ---- Server IP: 216.92.131.65 Probable Submitter: 152.160.39.70 ---- Manual Page -- http://www.php.net/manual/en/functions.anonymous.php Edit -- https://master.php.net/note/edit/89873 Del: integrated -- https://master.php.net/note/delete/89873/integrated Del: useless -- https://master.php.net/note/delete/89873/useless Del: bad code -- https://master.php.net/note/delete/89873/bad+code Del: spam -- https://master.php.net/note/delete/89873/spam Del: non-english -- https://master.php.net/note/delete/89873/non-english Del: in docs -- https://master.php.net/note/delete/89873/in+docs Del: other reasons-- https://master.php.net/note/delete/89873 Reject -- https://master.php.net/note/reject/89873 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#152485) next »