Is it possible to add an anonymous function to an object, and call it within the object. See below for example code. Calling closure assigned to object property directly and Anonymous function for a method of an object describe calling it directly, not within the object. Thank you
class myClass
{
public function go()
{
$this->scope;
}
}
$myObj=new myClass();
$myObj->scope=function()
{
echo('Print This!');
};
$myObj->go();