使用json_encode()时解析短数组语法时出错

eps*_*nes 2 php encoding json

我和一些团队分享我的工作.就我而言,这条线路json_encode(['Succeeded'])运行完美,在团队方面,这个消息失败了

Parse error: syntax error, unexpected '[', expecting ')' in /home/app/file.php on line *
Run Code Online (Sandbox Code Playgroud)

为什么会这样?

Luk*_*uke 6

我想你可能安装了两个不同版本的PHP.

版本5.4.0中引入了短数组语法.见http://php.net/manual/en/migration54.new-features.php

因此,以下内容可能适用于:

json_encode(array('Succeeded'));
Run Code Online (Sandbox Code Playgroud)