php8.5
Home/ Manual/ dom / domchildnode/ DOMChildNode::replaceWith

DOMChildNode::replaceWith

PHP function Edit on GitHub ✎

(PHP 8)

Replaces the node with new nodes

Description

DOMChildNode::replaceWith(DOMNode|string ...$nodes): void

Replaces the node with new nodes.

Parameters

nodes

The replacement nodes. Strings are automatically converted to text nodes.

Return Values

Void

Errors/Exceptions

Changelog

VersionDescription
8.3.0Calling this method on a node without a parent is now a no-op to align the behaviour with the DOM specification. Previous_hierarchy_exception

See Also

  • DOMChildNode::after
  • DOMChildNode::before
  • DOMChildNode::remove
  • DOMNode::replaceChild

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