Overview
KB
Technical FAQ
PHP Manual
CSS2 Manual
HTML Manual
JS Guide
JS Reference
PhpDock Manual
Nu-Coder Manual
PhpExpress Manual
PHP Joomla
Development
Learn PHP
 
<DOMElement::prependDOMElement::removeAttribute>
^DOMElementLast updated: Mon, 26 Oct 2026

DOMElement::remove

(PHP 8)

DOMElement::remove — Removes the element

Description

public function DOMElement::remove(): void

Removes the element.

Parameters

This function has no parameters.

Return Values

No value is returned.

Examples

Example #1 DOMElement::remove() example

Removes the element.

<?php
$doc = new DOMDocument;
$doc->loadXML("<container><hello/><world/></container>");
$hello = $doc->documentElement->firstChild;

$hello->remove();

echo $doc->saveXML();
?>

The above example will output:

<?xml version="1.0"?>
<container><world/></container>

See Also


<DOMElement::prependDOMElement::removeAttribute>
^DOMElementLast updated: Mon, 26 Oct 2026