(PHP 8)
DOMElement::after — Adds nodes after the element
Adds the passed nodes after the element.
nodesNodes to be added after the node. Strings are automatically converted to text nodes.
Не повертає значень.
DOM_HIERARCHY_REQUEST_ERR
Виникає, якщо тип батьківського вузла не дозволяє тип дочірнього вузла,
котрий передано в параметр nodes, або якщо вузол,
який потрібно додати, є одним із предків цього вузла або ним самим.
DOM_WRONG_DOCUMENT_ERR
Виникає, якщо один з переданих nodes було створено не
в тому документі, що і цей вузол.
| Версія | Опис |
|---|---|
| 8.3.0 |
Calling this method on a node without a parent is now a no-op to align the behaviour with the DOM specification.
Раніше викидалося виключення DOMException з кодом DOM_HIERARCHY_REQUEST_ERR.
|
| 8.3.0 |
Calling this method on a node without an owner document now works.
Раніше викидалося виключення DOMException з кодом DOM_HIERARCHY_REQUEST_ERR.
|
Приклад #1 DOMElement::after() example
Adds nodes after the hello element.
<?php
$doc = new DOMDocument;
$doc->loadXML("<hello/>");
$container = $doc->documentElement;
$container->after("beautiful", $doc->createElement("world"));
echo $doc->saveXML();
?>Поданий вище приклад виведе:
<?xml version="1.0"?> <hello/> beautiful <world/>