Is there a way to accomplish closure in PHP5.3 in the context of an object?
class Test { public $name='John'; function greet(){ eval('echo "Hello, ".$this->name;'); call_user_func(function(){ echo "Goodbye, ".$this->name; }); } } $c = new Test; $c->greet();
The eval () function will work fine, however, call_user_func will not have access to $ this. (Using $ this, if not in the context of the object). I pass "$ this" as an argument to close right now, but this is not quite what I need.
source share