php - 语法错误 PHP 5.3.3 - 意外的 '['

标签 php syntax-error php-5.3

这个问题在这里已经有了答案:





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/

相关文章:

ubuntu-12.04 - dpkg : error processing/var/cache/apt/archives/apache2-bin_2. 4.16-4+deb.sury.org~精确+4_i386.deb

php - Windows 服务器上的 OCI8 php 扩展安装

PHP Pubsubhubbub 服务器

laravel - 在共享主机上托管 Laravel 5.5 (T_VARIABLE) 错误

javascript - nodejs 中的语法 babel

寻找素数的 Haskell 列表理解

php - 替换 PHP 5.3 中的 UTF-8 字符

php - 单独文件上的引导模式不会关闭

javascript - 使用 PHP 变量作为 jQuery 中的变量

php - MySQL 子查询,需要帮助构建 Select 语句