After migrating from dev to prod on Bluehost when I run update.php I get a 500 error and I get the below error in error in error_log.

PHP Parse error: syntax error, unexpected T_FUNCTION in redhen_activity.module on line 608

This is D7 with the latest update to the Open Outreach Distribution. The odd thing is that my dev site (running as a subdomain) works just fine.

  • 1
    Your version of php isn't high enough, needs to be 5.3 or higher if it's an anonymous function on that line – Clive Aug 19 '16 at 0:22
  • Please check the PHP version on your dev and prod. – Jimmy Ko Aug 19 '16 at 0:38

Line 608 contains anonymous function.

$filtered = array_filter($message_types, function($var) {
  return strpos($var, 'redhen_') !== FALSE;

Here is the good explanation from DanChadwick on Drupal.org. Let me quote it here as well.

That line of code is an anonymous function. There are only 2 reasons I know of why PHP choke on an anonymous function.

1) Use of PHP < 5.3, where anonymous functions aren't supported.

2) Use of an opcode cache that doesn't support anonymous function. APC works. Searching the issue queue will reveal another that doesn't, whose name escapes me at the moment.

I'd venture that your other functioning sites either

a) aren't displaying components

b) are using an older version of webform,

c) are using a newer version of PHP or

d) aren't using the same op code cache.

So the best solution is to upgrade your PHP version.

To check your PHP version, either:

  1. use the PHP cli php -v or

  2. use the phpinfo() function.


I think you're using PHP 5.2 or earlier, which doesn't support closures. You can find out which version of PHP you're using phpinfo().

Lindly upgrade to PHP 5.3+, or use create_function, or write a static function and pass it as a callback.


Thanks for all your help. Unknown to me, Bluehost downgraded my PHP version. When they upgraded it to 5.6.24 everything worked. I battled this error for weeks! It was very frustrating!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.