php8.5
Home/ Manual/ dom / htmldocument/ Dom\HTMLDocument::createEmpty

Dom\HTMLDocument::createEmpty

PHP function Edit on GitHub ✎

(PHP 8 >= 8.4.0)

Creates an empty HTML document

Description

Dom\HTMLDocument::createEmpty(string $encoding = "UTF-8"): Dom\HTMLDocument

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

Dom\HTMLDocument::createEmpty example

Creates an empty document and serializes it.

php
<?php
$dom = Dom\HTMLDocument::createEmpty();
var_dump($dom->saveHtml());
?>

The above example will output:

output
string(0) ""

See Also

  • Dom\HTMLDocument::createFromString
  • Dom\HTMLDocument::createFromFile

Source: reference/dom/dom/htmldocument/createempty.xml · from the official PHP manual (php/doc-en)