According to Jason's suggestion about quick and dirty one-liner objects, I tried to create methods:
$obj = (object)array(
"handler" => function() { return "Doom"; }
);
Calling it the intuitive way fails:
echo $obj->handler();
//Fatal error: Call to undefined method stdClass::handler()
But this way works:
$fnptr = $obj->handler;
echo $fnptr();
// "Doom"
Albeit calling it from associative array (not object) runs without fatal error:
$arr = array(
"handler" => function() { return "Doom"; }
);
echo $arr["handler"]();
// "Doom"
Can you explain what's going on behind the scene? (I run on PHP 5.5.8)