(PHP 8 >= 8.4.0)
Dom\HTMLDocument::saveHtml — Serializes the document as an HTML string
Serializes the document as an HTML string.
nodeThe node to serialize. If not provided, the entire document is serialized.
The serialized HTML document string in the current document encoding.
Lancia una Dom\DOMException con codice
Dom\WRONG_DOCUMENT_ERR se node
proviene da un altro documento.
Example #1 Dom\HTMLDocument::saveHtml() example
Serializes a document to an HTML string.
<?php
$dom = Dom\HTMLDocument::createFromString('<!DOCTYPE html><p>Hello, world!</p>');
echo $dom->saveHtml();
?>Il precedente esempio visualizzerà:
<!DOCTYPE html><html><head></head><body><p>Hello, world!</p></body></html>