I have a weird problem trying to use closures in PHP. When assigning a closure to a variable, I get a null
value. But when displaying the closure with var_dump()
, everything is alright.
Here is a source code that summarizes the problem:
$f = function() {};
var_dump($f); // 'null'
var_dump(function() {}); // 'object(Closure)[1]'
I'm using PHP 5.3.1.
Edit: I forgot to mention, I have this problem only when I'm using PHP via Apache. I don't have issues when using PHP CLI.
A colleague found the answer to the problem: the responsible is eAccelerator! Apparently it's not compatible with PHP 5.3 closures... (source)
Disabling it solved the problem.
Thanks for your help!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With