There's a million hits for this subject and none of them seem to have worked for me. So I have to ask it again. Say, if I have this:
$html = ""PHP" is documented <a href=\"https://php.net\">here</a>.";
$dom = new DOMDocument();
$dom->strictErrorChecking = false;
$dom->preserveWhiteSpace = true;
$dom->loadHTML($html, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
$newHtml = $dom->saveHTML();
echo(htmlentities($newHtml));
Why as an output I'm getting:
<p>"PHP" is documented <a href="https://php.net">here</a>.</p>
Where's this <p> coming from? Didn't I ask not to do it in LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD?
Anyway, does someone have a solution to this that works?