Skip to content

Instantly share code, notes, and snippets.

@vstarck
Created June 14, 2012 00:03
Show Gist options
  • Save vstarck/2927234 to your computer and use it in GitHub Desktop.
Save vstarck/2927234 to your computer and use it in GitHub Desktop.
broken.lambdas2.php
<?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