声明应与PHP 7

时间:2017-02-02 23:03:01

标签: php wordpress

我将我的网站升级到PHP 7,现在在前端出现此错误:

Warning: Declaration of Works_Walker::start_el(&$output, $category, $depth, $args) should be compatible with Walker_Category::start_el(&$output, $category, $depth = 0, $args = Array, $id = 0)

这引用的代码是:

 class Works_Walker extends Walker_Category {
 function start_el(&$output, $category, $depth, $args) 

当我编辑此代码以匹配父代时,我收到语法错误。

class Works_Walker extends Walker_Category {
function start_el(&$output, $category, $depth = 0, $args = Array, $id = 0)

"数组"似乎是语法错误的原因。我希望这对诊断有用。

1 个答案:

答案 0 :(得分:2)

Array是一种类型。您正在寻找array()(或[]),因为您要分配默认的。即$args = Array应为$args = array()。以供参考: 4.7.2/Walker_Category