我有下面的代码,但是,我在我的代码中出现错误。 我找不到问题,但我认为它来自: UserManagement :: findByUsername($ username);无效的参数foreach()
$a_allSections = UserManagement::findByUsername($username);
if($a_allSections)
{
foreach($a_allSections as $a_section)
{
echo $a_section['name'];?>
}
}
else
{
echo 'There's nothing found.' . "\n";
}
什么类型是你的'$ a_allSections'这样的错误? – hsz 2012-03-01 10:30:40
更好的检查可能是'if(is_array($ a_allSections))' – 2012-03-01 10:30:51
@andreas,返回的对象可以是包含迭代器的对象。 – hsz 2012-03-01 10:31:56