This will return error:
FATAL ERROR Uncaught Error: Call to undefined method stdClass::myfunc() in /var/www/html/index.php81(4) : eval()'d code:10 Stack trace: #0 /var/www/html/index.php81(4): eval() #1 {main} thrown on line number 10
How can I make this work?
<?php
$data = (object) [];
$data->foo = "whatever";
$data->myfunc = function () {
echo "Yeah";
};
$data->myfunc(); // this makes error
call_user_func($data->myfunc); // this works as expected, strange