Created
June 14, 2012 00:03
-
-
Save vstarck/2927234 to your computer and use it in GitHub Desktop.
broken.lambdas2.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Foo { | |
public function __construct() { | |
$this->bar = function() { | |
echo 'Hello World!'; | |
}; | |
} | |
} | |
$f = new Foo; | |
//Fatal error: Call to undefined method Foo::bar() in foo.php on line 84 | |
$f->bar(); | |
// OK | |
$bar = $f->bar; | |
$bar(); // Hello World! | |
// OK | |
$f->bar->__invoke(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment