2013-03-18 100 views
2

我收到以下警告:陣列錯誤/警告

Warning: reset() expects parameter 1 to be array, null given in /data/9/1/115/118/1767118/user/1910351/htdocs/aw/home/wp-content/themes/awthemesnew/library/sidebars.php on line 183 

記住我編輯wordpress的PHP文件。以下是183行的完整代碼:

function theme_print_sidebar($name, $places) { 
    $style = theme_get_option('theme_sidebars_style_' . $name); 
    $place_count = count($places); 
    if ($name != 'footer' && $place_count < 2) { 
     theme_print_widgets(reset($places), $style); 
     return; 
    } 
    ?> 

幫助。謝謝!

回答

2

$位置的值在您重置時顯然爲空。

您的代碼是說「僅當$ place_count的值小於2時調用重置」。 你通過陳述,$ place_count的價值:

$place_count = count($places); 

我們可以推斷,當計()調用空變量則返回0。因爲0小於2,下列說法執行:

theme_print_widgets(reset($places), $style); 

但是,在這一點上,$ places爲null這一事實會導致錯誤。我很想知道在什麼情況下$ places是空的。一旦你得到了答案,你可以決定如何處理這種情況。

+0

以下是發生錯誤的頁面:http://www.aromaticwaters.com/home/product-category/diffusers/ – user2184436 2013-03-20 19:54:19

0

我想通了。我在頁腳中刪除了一條命令,當代碼找到它時,它已經消失了,它給了我一個數組警告。謝謝您的幫助。