I have this code but I am stuck…
$my_var = function (){
return array('hello you');
};
var_dump($my_var); // returns object(Closure)#2 (0) { }
how do I echo $my_var?
I would assume it would be echo $my_var[0]; but this does not work.
Fatal error: Cannot use object of type Closure as array in ...
A closure is a function.
Therefore you have to call it, like this :
Since php5.4 with Array Access: