# Dom\HTMLDocument::createEmpty

(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.

### 参数

`encoding`
  The character encoding of the document, used for serialization when calling the save methods.

### 返回值

An empty HTML document.

### 示例

示例 #1 Dom\HTMLDocument::createEmpty() example

Creates an empty document and serializes it.

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

以上示例会输出：

    string(0) ""

### 参见

- Dom\HTMLDocument::createFromString() - Parses an HTML document from a string
- Dom\HTMLDocument::createFromFile() - Parses an HTML document from a file

`↑` and `↓` to navigate • `Enter` to select • `Esc` to close • `/` to open