php8.5
Home/ Manual/ dom / domdocumentfragment/ DOMDocumentFragment::append

DOMDocumentFragment::append

PHP function Edit on GitHub ✎

(PHP 8)

Appends nodes after the last child node

Description

DOMDocumentFragment::append(DOMNode|string ...$nodes): void

Appends one or many nodes to the list of children after the last child node.

Examples

DOMDocumentFragment::append example

Appends nodes in the fragment.

php
<?php
$doc = new DOMDocument;
$fragment = $doc->createDocumentFragment();
$fragment->appendChild($doc->createElement("hello"));

$fragment->append("beautiful", $doc->createElement("world"));

echo $doc->saveXML($fragment);
?>

The above example will output:

output
<hello/>beautiful<world/>

See Also

  • DOMParentNode::append
  • DOMDocumentFragment::prepend

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