【问题标题】:PHP, Parse error: syntax error, unexpected T_FUNCTION [duplicate]PHP,解析错误:语法错误,意外的 T_FUNCTION [重复]
【发布时间】:2012-07-11 04:28:14
【问题描述】:
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 错误消息得到非常相关的结果,这里是真的。

标签: syntax syntax-error php


【解决方案1】:

检查你的 PHP 版本,匿名函数只支持 5.3+

【讨论】:

  • 我认为 PHP5 支持 array_walk_recursive
  • 我遇到了类似的问题,将 PHP 版本更改为 5.4。意味着mysql 将被弃用,因此您必须使用mysqliPDO
猜你喜欢
  • 1970-01-01
  • 2011-07-23
  • 2012-05-11
  • 2011-06-24
  • 1970-01-01
  • 1970-01-01
  • 2011-04-13
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多