|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2011-03-19 04:14 UTC] dan dot lugg at gmail dot com
Description:
------------
Feature request for 'use implicit', or semantically similar syntax. Anonymous functions with the use implicit directive inherit all variables from parent scope in which they are declared, not called;
$foo = 'hello';
call_user_func(function() use implicit{
echo $foo; // hello
});
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 21:00:01 2025 UTC |
Further examples exhibiting scope inheritance: class Test{ public $func; public function callFunc(){ $this->func(); } } $foo = 'hello'; $test = new Test; $test->func = function() use implicit{ echo $foo; } $test->callFunc(); // hello