2017-02-02 74 views
2

我升級我的網站PHP 7,現在得到這個錯誤在前端:聲明應該與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

它告訴你在消息中的權利。您的函數簽名必須與您正在擴展的接口/函數簽名匹配。這包括「默認」值。 – noahnu

+0

[方法聲明應該與PHP中的父級方法兼容]的可能重複(http://stackoverflow.com/questions/3115388/declaration-of-methods-should-be-compatible-with-parent-methods-in- php) – noahnu

+0

感謝您的鏈接和解釋。不幸的是我找不到我之前發佈的代碼中的任何代碼引用到我的網站Walker_Category。我不確定我可以在哪裏更改這些簽名以匹配它們。 – user3612498

回答

2

Array是一種類型。您正在尋找array()(或[]),因爲您正在分配默認的。即$args = Array應該是$args = array()。作爲參考: 4.7.2/Walker_Category

+0

修好了!感謝您的幫助。 – user3612498

相關問題