【发布时间】:2021-07-06 18:00:38
【问题描述】:
我有一段代码,是用php7写的:
[$columns, $values, $conditions] = $this->gatherConditions($identifier);
$identifier 是一个数组。当我在 php5.6 服务器上运行此代码时,它显示错误 - unexpected "=" on line X。在 php 5.6 中应该如何编写这行代码?
【问题讨论】:
我有一段代码,是用php7写的:
[$columns, $values, $conditions] = $this->gatherConditions($identifier);
$identifier 是一个数组。当我在 php5.6 服务器上运行此代码时,它显示错误 - unexpected "=" on line X。在 php 5.6 中应该如何编写这行代码?
【问题讨论】:
在 PHP 7.1 中允许使用短数组语法列表解构之前,PHP 中的等效项是
list($columns, $values, $conditions) = $this->gatherConditions($identifier);
查看 php.net/list 页面:https://www.php.net/manual/en/function.list.php
【讨论】: