エラーが発生し、考えられるすべてのことをほとんど洞察なしでグーグルで検索しました。たぶん、あなたは新鮮な目のセットを手伝うことができます。
オブジェクトの配列を返す関数があります。次に、この関数を呼び出すコードは、この配列をループして、各オブジェクトで必要な処理を実行します。HTMLを吐き出すと視覚的に機能するように見えますが、サーバーログには「foreach()に無効な引数が指定されました」というエラーが表示されます。ええ、それが技術的に機能するのは素晴らしいことですが、私はこのエラーがもうポップアップしないようにしたいです。考え?
<?php
// The class whose method returns an array of library_Label objects
class library_Label
{
public $id = null;
public $name = null;
public function getChildren()
{
// $children is declared earlier
return $children;
}
}
// main code
$columns = new library_Label(1);
foreach ($columns->getChildren() as $label) echo $label->Name;
?>