所以我想弄清楚,为什么 PHP 7.1.1 会为以下 _construct 函数抛出错误:
function __construct( $field = array(), $value ='', $parent ) {
//parent::__construct( $parent->sections, $parent->args );
$this->parent = $parent;
$this->field = $field;
if (empty($this->field['class']))
$this->field['class'] = '';
$this->value = $value;
$this->args = $parent->args;
}
我得到这个错误。
警告:第 34 行 D:\Servers\Web Server\les.local.dev\wp-content\themes\mts_onepage\options\fields\layout\field_layout.php 中的非法字符串偏移 'class'
警告:无法将空字符串分配给第 34 行 D:\Servers\Web Server\les.local.dev\wp-content\themes\mts_onepage\options\fields\layout\field_layout.php 中的字符串偏移量
如果我删除 IF 部分,它检查是否$this->field['class']
为空,错误就会消失。
我知道 PHP 7.1 改变了数组的工作方式,但我仍然不明白。