# DOMNode::contains

(PHP 8 >= 8.3.0)

DOMNode::contains — Checks if node contains other node

### Beschreibung

public DOMNode::contains(DOMNode|DOMNameSpaceNode|null `$other`): bool

Checks if node contains `other` node.

### Parameter-Liste

`other`

  Node to be checked.

### Rückgabewerte

Returns `true` if node contains `other` node, `false` otherwise.

### Beispiele

Beispiel #1 DOMNode::contains() example

`<?php
$dom = new DOMDocument();
$dom->loadXML(<<<XML
<!DOCTYPE HTML>
<html>
<body>
<main>
<p>Hello, world!</p>
</main>
</body>
</html>
XML);
$xpath = new DOMXPath($dom);
$main = $xpath->query("//main")[0];
var_dump($dom->documentElement->contains($main));
?>`

Das oben gezeigte Beispiel erzeugt folgende Ausgabe:

    bool(true)

`↑` and `↓` to navigate • `Enter` to select • `Esc` to close • `/` to open