I wonder why this is not working: ( PHP Fatal error: Call to undefined method stdClass::y()
)
$x=new stdClass;
$x->y=function(){return 'hi';};
echo $x->y();
but it works:
$x=new stdClass;
$x->y=function(){return 'hi';};
$y=$x->y;
echo $y();
echo ($x->y)();
also return Parse error: syntax error, unexpected '(', expecting ',' or ';'
invalid. So, what is the correct way to call a y
closure property without intermediate variables.
Phpst source
share