PHP Version 5.2.14/Parse error:语法错误,意外的T_FUNCTION,期待')'

tzm*_*447 5 php parsing parse-error

我有一段代码,我正在尝试使用PHP 5.2.14版.它不兼容吗?我运行以下,

jailshell-3.2$ php -l /XYZ/functions.php
Run Code Online (Sandbox Code Playgroud)

它给出了:

解析错误:语法错误,意外的T_FUNCTION,在第2115行的/XYZ/functions.php中期待')'错误解析/XYZ/functions.php

代码是:

2114    $range = array_map(
2115                function (DatePeriod $p) use ($vt2) {
2116               $res = array();
Run Code Online (Sandbox Code Playgroud)

sha*_*mar 6

您的代码使用anonymous functionsPHP 5.3中支持的代码.因此,您需要PHP 5.3才能使其正常运行.升级服务器的PHP安装.

匿名函数(也称为闭包)允许创建没有指定名称的函数.