这个问题在这里已经有了答案:
PHP parse/syntax errors; and how to solve them
(21 个回答)
6年前关闭。
如何更正以下 php 片段以在 php 5.3.3 中运行它而不会出现解析错误?
浏览器消息
Parse error: syntax error, unexpected '['
PHP 代码片段
{ public function getDelete($key = NULL) $_DELETE = [];
parse_str(file_get_contents("php://input"), $_DELETE);
return NULL !== $key ? self::arrayKey($key, $_DELETE) : $_DELETE;
}
错误日志消息:
mod_fcgid: stderr: PHP Parse error: syntax error, unexpected '['
最佳答案
PHP 5.3 不支持 []
数组语法。只有 PHP 5.4 及更高版本可以。
对于较旧的 PHP,您需要使用 array()
而不是 []
.
关于php - 语法错误 PHP 5.3.3 - 意外的 '[',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32380833/