xref: /PHP-8.4/ext/simplexml/tests/030.phpt (revision 7f2f0c00)
1--TEST--
2SimpleXML: isset and unset by offset
3--EXTENSIONS--
4simplexml
5--FILE--
6<?php
7$xml =<<<EOF
8<root s:att1="b" att1="a"
9      xmlns:s="urn::test" xmlns:t="urn::test-t">
10   <child1>test</child1>
11   <child1>test 2</child1>
12   <s:child3 />
13</root>
14EOF;
15
16$sxe = simplexml_load_string($xml);
17
18echo $sxe->child1[0]."\n";
19echo $sxe->child1[1]."\n\n";
20
21var_dump(isset($sxe->child1[1]));
22unset($sxe->child1[1]);
23var_dump(isset($sxe->child1[1]));
24echo "\n";
25
26$atts = $sxe->attributes("urn::test");
27var_dump(isset($atts[0]));
28unset($atts[0]);
29var_dump(isset($atts[0]));
30var_dump(isset($atts[TRUE]));
31
32?>
33--EXPECT--
34test
35test 2
36
37bool(true)
38bool(false)
39
40bool(true)
41bool(false)
42bool(false)
43