Dom\HTMLDocument::createEmpty
(PHP 8 >= 8.4.0)
Dom\HTMLDocument::createEmpty — Creates an empty HTML document
Description
Creates an empty HTML document without any elements.
Parameters
encoding
The character encoding of the document, used for serialization when calling the save methods.
Return Values
An empty HTML document.
Examples
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) ""
See Also
- Dom\HTMLDocument::createFromString() - Parses an HTML document from a string
- Dom\HTMLDocument::createFromFile() - Parses an HTML document from a file
来源:PHP Documentation Group · 作者与贡献记录 · CC BY 3.0。离线整理了版式、链接和媒体显示。
