2013-03-18 95 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

我想通了。我在页脚中删除了一条命令,当代码找到它时,它已经消失了,它给了我一个数组警告。谢谢您的帮助。