PHP,解析错误:语法错误,意外的T_FUNCTION [英] PHP, Parse error: syntax error, unexpected T_FUNCTION

查看:216
本文介绍了PHP,解析错误:语法错误,意外的T_FUNCTION的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

错误在于:

array_walk_recursive($decoded_data,function(&$function)

推荐答案

检查您的PHP版本,仅5.3+支持匿名功能

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

这篇关于PHP,解析错误:语法错误,意外的T_FUNCTION的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆