ここには について約 100 の異なる質問があるようですCreating default object from empty value
。それらのどれも私の問題に実際に役立つようには見えません。
メソッドで同じクラスの子オブジェクトを割り当てています。これにより、Creating default object from empty value
エラーが発生します。
class myClass {
function __construct($rootName, $allowHTML = false, $endTag = true) {
$this->rootElement = $rootName;
$this->elements = array();
$this->attributes = array();
$this->value = "";
$this->allowHTML = $allowHTML;
$this->endTag = $endTag;
$this->styles = array();
$this->childID = 0;
}
// ... OTHER METHODS HERE (ALL PROPERTIES DECLARED)
function assignElement(&$theElement) {
// Get the index.
$index = count($this->elements);
// Assign the element.
$this->elements[$index] = $theElement;
if (get_class($theElement) == get_class($this)) {
$this->elements[$index]->childID = $index;
}
// Return the node.
return $this->elements[$index];
}
}
でエラーが発生し$this->elements[$index]->childID = $index;
ます。これを適切に処理するにはどうすればよいですか?