Dom\HTMLDocument::saveHtml

(PHP 8 >= 8.4.0)

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

Descrizione

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

Serializes the document as an HTML string.

Elenco dei parametri

node

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

Valori restituiti

The serialized HTML document string in the current document encoding.

Errori/Eccezioni

Esempi

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>

Vedere anche:

User Contributed Notes

There are no user contributed notes for this page.
Adding new notes is disabled. Please see the links in the Found A Problem? section.
To Top