我以为会是这样的:
class Object
{
public $ID;
public $Name;
}
我使用array_push($Objects, $Obj);
for ( $d = 0; $d < count($Objects); $d++)
{
echo $Objects[$d]->Name;
}
php给我一个错误说&#34;试图获取非对象的属性...&#34;
答案 0 :(得分:0)
class Object
{
public $ID;
public $Name = 'N';
}
$Objects =array();
array_push($Objects,new Object());
array_push($Objects,new Object());
array_push($Objects,new Object());
foreach($Objects as $obj){
echo $obj->Name;
}
// NNN