$doc=new DOMDocument("1.0","UTF-8"); $doc->formatOutput=true; $ul[]=$doc->appendChild($doc->createElement("ul")); $ul[]=$doc->appendChild($doc->createElement("ul")); $ul[]=$doc->appendChild($doc->createElement("ul")); $li=$ul[$i]->appendChild($doc->createElement("li")); //tutaj jest błąd $a=$li->appendChild($doc->createElement("a")); $a->setAttribute("href","/company/" . $row['url']); $text=$a->appendChild($doc->createTextNode($row['name'])); $e++; if ($e==4) { $i++; $e=0; } }
I dostaję taki błąd w linii z komentarzem:
Call to a member function appendChild() on a non-object
Nie mam pojęcia co się stało. Kiedy ten kod był wewnątrz funkcji w klasie, wszystko było ok.