xref: /PHP-5.6/ext/simplexml/tests/014b.phpt (revision 610c7fbe)
1--TEST--
2SimpleXML: adding/removing attributes (second)
3--SKIPIF--
4<?php if (!extension_loaded("simplexml")) print "skip"; ?>
5--FILE--
6<?php
7$xml =<<<EOF
8<people>
9   <person name="Joe"></person>
10   <person name="Boe"></person>
11</people>
12EOF;
13
14$people = simplexml_load_string($xml);
15var_dump($people->person[0]['name']);
16var_dump($people->person[1]['age']);
17$person = $people->person[1];
18$person['name'] = "XXX";
19var_dump($people->person[1]['name']);
20$people->person[1]['age'] = 30;
21var_dump($people->person[1]['age']);
22echo "---Unset:---\n";
23unset($people->person[1]['age']);
24echo "---Unset?---\n";
25var_dump($people->person[1]['age']);
26var_dump(isset($people->person[1]['age']));
27echo "---Unsupported---\n";
28$people->person[1]['age'] += 5;
29var_dump($people->person[1]['age']);
30?>
31===DONE===
32--EXPECTF--
33object(SimpleXMLElement)#%d (1) {
34  [0]=>
35  string(3) "Joe"
36}
37NULL
38object(SimpleXMLElement)#%d (1) {
39  [0]=>
40  string(3) "XXX"
41}
42object(SimpleXMLElement)#%d (1) {
43  [0]=>
44  string(2) "30"
45}
46---Unset:---
47---Unset?---
48NULL
49bool(false)
50---Unsupported---
51object(SimpleXMLElement)#%d (1) {
52  [0]=>
53  string(1) "5"
54}
55===DONE===
56