I have a local Drupal site running with MAMP on Win 7 with php 5.6.13. My live site has php 5.6.17. I have no problems on the local site, but on the live site I get unexpected T function error with the following code which I downloaded from drupal.org.
function redhen_activity_message_types() {
$message_types = array_keys(message_type_load());
$filtered = array_filter($message_types, function($var) {
return strpos($var, 'redhen_') !== FALSE;
});
return $filtered;
}
The line beginning with $filtered is the one that is pointed to by the error message.
I know little about php, but have been searching the web and found something called anonymous functions not working on older versions of php. Is the slightly different versions of php causing this problem? How do I fix it?
Thanks!
The anonymous function is the function that's defined starting in that line of code:
function($var) {
return strpos($var, 'redhen_') !== FALSE;
}
I don't see anything obviously wrong with that function, and Redhen CRM gets enough use that others are likely to have run into problems already if it were clearly incorrect. And while it's always good to test under the same version as your production environment it's unlikely that there was bug introduced to PHP between 5.6.13 and 5.6.17 that's causing this problem.
To find the root cause try a few things:
php --version
on the command line gave the wrong answer. Use a phpinfo()
call to verify the version.