3

I can't figure out what's wrong here. Here's my test.php file:

<?php
error_reporting(E_ALL);
echo phpversion();
$arr = array ();

$attrs = array_filter((array)$arr, function($v) {
    return ($v || $v === 0 || $v === '0');
}); 

The output of this script is:

5.3.3 Warning: array_filter() expects parameter 2 to be a valid callback, no array or string given in /path/test.php on line 8

How can that be? I thought PHP 5.3 supported lambdas.

2
  • It works in my local environment, but in production, I get this. Does anyone have any idea what I would check in my PHP configuration that might be somehow blocking the use of lambdas? Honestly, I can't even believe what I'm seeing. I makes absolutely no sense to me. Commented Jun 29, 2012 at 13:53
  • If I crank down my error reporting to E_ERROR, it works. But that's not ideal. Commented Jun 29, 2012 at 14:30

1 Answer 1

3

This was related to a bug in eAccelerator, which had a problem caching opcode that used lambdas. Updated to the latest version of eAccelerator and it is fixed.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.