PHP,解析错误:语法错误,意外的T_FUNCTION [duplicate]

时间:2021-12-29 01:26:04

This question already has an answer here:

这个问题已经有了答案:

class test
{
    public $do;
    function __construct($data="")
    {
        $this->parse($data);
    }
    private function parse($data)
    {
        // Decoding the functions
        $decoded_data = json_decode($data,true); 
        array_walk_recursive($decoded_data,function(&$function) {
            $first_line = strtok($function, "\n");
            preg_match("/\/\*#(.*?)\#*\//",$first_line,$matches);
            $function = create_function($matches[1],$function);
        });
        $this->do = $decoded_data;  
    }
}

Parse error: syntax error, unexpected T_FUNCTION

解析错误:语法错误,意外的T_FUNCTION。

The error is in:

的错误是:

array_walk_recursive($decoded_data,function(&$function)

array_walk_recursive(decoded_data美元,函数(& $函数)

1 个解决方案

#1


11  

Check your PHP version, anonymous functions are only supported on 5.3+

检查PHP版本,在5.3+中只支持匿名函数

#1


11  

Check your PHP version, anonymous functions are only supported on 5.3+

检查PHP版本,在5.3+中只支持匿名函数