Call function from an object?

oop, php

Solution

Anonymous or not, you have a callback function, thus you need to handle it as such. E.g.:

<?php

$ar = (object) array(
    'a' => function(){
        echo 'TEST';
    }
);

call_user_func($ar->a);

?>

Problem

``` <?php $ar = (object) array('a'=>function(){ echo 'TEST'; }); $ar->a(); ?> ``` I get this error Call to undefined method

Original source

Related problems