0

我一直在为一个项目创建一个 php 脚本,并一直在运行 PHP 5.4.17 的开发服务器上运行它

我需要将其移至运行 PHP 5.4.19 的生产服务器

在我的开发服务器上使用该array_map功能时,我得到了我需要的结果,没有问题。

在我的生产服务器上,我收到解析错误:

Parse error: syntax error, unexpected '[' in /path/to/script/ on line 219

我使用的代码是:

$arr = array_map(
    function($results_titles, $results_image, $results_summary, $results_dates, $results_links) {
        return ['title' => $results_titles, 'image' => $results_image, 'summary' => $results_summary, 'date' => $results_dates, 'link' => $results_links];
    },
    $results_titles, $results_image, $results_summary, $results_dates, $results_links
);
4

1 回答 1

2

PHP 5.4 提供了新的数组语法。

因此,请确保您服务器中的 php 版本 >= PHP 5.4

注意:cli 和 web 服务器(例如:apache)可以运行不同版本的 php。

于 2014-02-18T08:19:08.477 回答