(PHP 8 >= 8.4.0)
Dom\HTMLDocument::createEmpty — Creates an empty HTML document
public static Dom\HTMLDocument::createEmpty(string $encoding = "UTF-8"): Dom\HTMLDocument
Creates an empty HTML document without any elements.
encodingAn empty HTML document.
Example #1 Dom\HTMLDocument::createEmpty() example
Creates an empty document and serializes it.
<?php $dom = Dom\HTMLDocument::createEmpty(); var_dump($dom->saveHtml()); ?>
The above example will output:
string(0) ""
© 1997–2025 The PHP Documentation Group
Licensed under the Creative Commons Attribution License v3.0 or later.
https://www.php.net/manual/en/dom-htmldocument.createempty.php