I have the following lines of code in my application:
$d = function(){
return 5;
};
var_dump($d, gettype($d));
exit;
When I execute this code in my application it outputs:
NULL string(4) "NULL"
This surprises me, how can $d by NULL after it has been assigned an anonymous function?
When I run the exact same code in a separate PHP file on the same webserver under the same vhost / config it outputs:
object(Closure)#1 (0) {} string(6) "object"
So it seems to be something with my PHP application which is built with Zend Framework. But I can't understand what my application could have done to mess up this core behavior. I am experiencing this problem with PHP 5.3.2 on CentOS 5.8. Any directions on whats going on here are welcome since I'm all out of ideas on this one.
Edit: Also when trying to running $d()
in the non-working case PHP says:
Fatal error: Function name must be a string in /Bootstrap.php on line 118
Strange wording of the error since the language now accepts anonymous functions, but this code gives me te same error so it seems to be the correct message:
$a = null;
$a();