You're right, it's just a documentation issue. Where it says
Sets HTML_PARSE_NOIMPLIED flag, which turns off the automatic adding of implied html/body... elements.
it should really say
Sets HTML_PARSE_NOIMPLIED flag, which moves arbitrary content inside script tags, because if you wanted an actual HTML parser and not a half-broken XML parser with "HTML" drawn on in crayon, you wouldn't be using PHP.
Hmm, is that strictly incorrect behaviour? It is using
LIBXML_HTML_NOIMPLIED, after all.If it is incorrect, given it's using libxml (I checked), wouldn't the problem not be with PHP per se?
You're right, it's just a documentation issue. Where it says
it should really say
My guess is a DOM document needs a root element, so if it can't imply HTML tags, it has to use the first element.
Most other "loose" HTML parsers create an <html> element as the root.
Right, but here a flag has been used to disable that.