PHP, Parse error: syntax error, unexpected T_FUNCTION [duplicate]

心不动则不痛 提交于 2019-11-28 11:29:33

问题


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

The error is in:

array_walk_recursive($decoded_data,function(&$function)


回答1:


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



来源:https://stackoverflow.com/questions/11425559/php-parse-error-syntax-error-unexpected-t-function

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!