1--TEST--
2Test whether a node has child nodes: hasChildNodes()
3--EXTENSIONS--
4dom
5--FILE--
6<?php
7
8/* Create an XML document
9 * with structure
10 * <book>
11 *  <title>This is the title</title>
12 * </book>
13 * Check for child nodes of the <book>, <title> and This is the title
14 *
15*/
16
17$doc = new DOMDocument();
18
19$root = $doc->createElement('book');
20$doc->appendChild($root);
21
22$title = $doc->createElement('title');
23$root->appendChild($title);
24
25$text = $doc->createTextNode('This is the title');
26$title->appendChild($text);
27
28echo "Root has child nodes: ";
29var_dump($root->hasChildNodes());
30
31echo "Title has child nodes: ";
32var_dump($title->hasChildNodes());
33
34echo "Text has child nodes: ";
35var_dump($text->hasChildNodes());
36
37?>
38--EXPECT--
39Root has child nodes: bool(true)
40Title has child nodes: bool(true)
41Text has child nodes: bool(false)
42