summaryrefslogtreecommitdiff
path: root/ext/dom/tests/DOMNode_hasChildNodes_basic.phpt
blob: 3a6f6b4218886a6f416837b020526553c78c68e4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
--TEST--
Test whether a node has child nodes: hasChildNodes()
--SKIPIF--
<?php
include('skipif.inc');
?>
--FILE--
<?php 

/* Create an XML document
 * with strcuture
 * <book> 
 *  <title>This is the title</title>
 * </book>
 * Check for child nodes of the <book>, <title> and This is the title
 *
*/

$doc = new DOMDocument();

$root = $doc->createElement('book');
$doc->appendChild($root);

$title = $doc->createElement('title');
$root->appendChild($title);

$text = $doc->createTextNode('This is the title');
$title->appendChild($text);

echo "Root has child nodes: ";
var_dump($root->hasChildNodes());

echo "Title has child nodes: ";
var_dump($title->hasChildNodes());

echo "Text has child nodes: ";
var_dump($text->hasChildNodes());

?>
--EXPECTF--
Root has child nodes: bool(true)
Title has child nodes: bool(true)
Text has child nodes: bool(false)