Edit report at http://bugs.php.net/bug.php?id=54311&edit=1

 ID:                 54311
 User updated by:    dan dot lugg at gmail dot com
 Reported by:        dan dot lugg at gmail dot com
 Summary:            Implicit variable scope declaration
 Status:             Open
 Type:               Feature/Change Request
 Package:            *Programming Data Structures
 Operating System:   Windows 7 x64
 PHP Version:        Irrelevant
 Block user comment: N
 Private report:     N

 New Comment:

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


Previous Comments:
------------------------------------------------------------------------
[2011-03-19 04:14:28] 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

});



------------------------------------------------------------------------



-- 
Edit this bug report at http://bugs.php.net/bug.php?id=54311&edit=1

Reply via email to