Serializes the document as an HTML string

- « Dom\HTMLDocument::createFromString

- Dom\HTMLDocument::saveHtmlFile »

- PHP Manual
- Dom\HTMLDocument
- Serializes the document as an HTML string

# Dom\HTMLDocument::saveHtml

(PHP 8 >= 8.4.0)

Dom\HTMLDocument::saveHtml — Serializes the document as an HTML string

### Description

public Dom\HTMLDocument::saveHtml(?Dom\Node `$node` = `null`): string

Serializes the document as an HTML string.

### Parameters

`node`
  The node to serialize. If not provided, the entire document is serialized.

### Return Values

The serialized HTML document string in the current document encoding.

### Errors/Exceptions

- Throws a Dom\DOMException with code `Dom\WRONG_DOCUMENT_ERR` if `node` is from another document.

### See Also

- Dom\HTMLDocument::saveHtmlFile() - Serializes the document as an HTML file
- Dom\HTMLDocument::saveXml() - Serializes the document as an XML string