我将我的网站升级到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)
"数组"似乎是语法错误的原因。我希望这对诊断有用。
答案 0 :(得分:2)
Array
是一种类型。您正在寻找array()
(或[]
),因为您要分配默认的值。即$args = Array
应为$args = array()
。以供参考:
4.7.2/Walker_Category