How can PHP DOM functions handle escaping characters like <&>" automatically?

PHP DOM functions can automatically handle escaping characters like <&>" by using the `createTextNode` method to create text nodes within the DOM. This method will automatically escape special characters, ensuring that the content is rendered correctly without the need for manual escaping.

// Create a new DOMDocument
$doc = new DOMDocument();

// Create a text node with special characters
$text = $doc-&gt;createTextNode(&#039;&lt;Hello &amp; World&gt;&#039;);

// Append the text node to the document
$doc-&gt;appendChild($text);

// Output the HTML
echo $doc-&gt;saveHTML();