这段代码在PHP 7.1.6下引发了警告......在PHP 5.xx下它没有任何问题.
违规行是$attributes['onclick'] = $onclick;警告Illegal string offset 'onclick'.
这是我的代码:
protected function js_anchor($title, $onclick = '', $attributes = '')
{
if ($onclick)
{
$attributes['onclick'] = $onclick;
}
if ($attributes)
{
$attributes = _parse_attributes($attributes);
}
return '<a href="javascript:void(0);"'.$attributes.'>'.$title.'</a>';
}
Run Code Online (Sandbox Code Playgroud) php ×1