Search code examples
phpphp-closures

No closure support in PHP 5.3.2-1ubuntu4.2


I just realised that a bit of PHP doesn't execute correctly on one server, but it does on another.

They're both running Ubuntu 10.04 with PHP PHP 5.3.2 (PHP 5.3.2-1ubuntu4.2 with Suhosin-Patch (cli) (built: May 13 2010 20:03:45))

I'm testing using:

$f = function() {};

var_dump($f);
die();

On the server that works, the result is:

object(Closure)#1 (0) { }

On the one that doesn't, the result is:

UNKNOWN:0

What am I missing?

[edit]

There seems to be an issue with having 2 closures in the same file:

<?php
$f = function() {};
$f2 = function() {};

var_dump($f);
var_dump($f2);
die();

Outputs:

UNKNOWN:0
object(Closure)#1 (0) {}


Solution

  • After some more Googling combined with ircmaxell's tip at phpinfo, I got a hint at eaccelerator.

    The server that ran the code correctly was running eaccelerator 0.9.6.1, the one that didn't work was using 0.9.6.

    Compiled the new version from source and it fixed my issue.

    Thanks!