summaryrefslogtreecommitdiff
path: root/ext/simplexml/tests/014.phpt
blob: d1d736e7b59ce1874ddee303388da5296f447d95 (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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
--TEST--
SimpleXML: adding/removing attributes (direct)
--SKIPIF--
<?php if (!extension_loaded("simplexml")) print "skip"; ?>
--FILE--
<?php 
$xml =<<<EOF
<people>
   <person name="Joe"></person>
</people>
EOF;

$people = simplexml_load_string($xml);
var_dump($people->person['name']);
var_dump($people->person['age']);
$person = $people->person;
$person['name'] = "XXX";
var_dump($people->person['name']);
$people->person['age'] = 30;
var_dump($people->person['age']);
echo "---Unset:---\n";
unset($people->person['age']);
echo "---Unset?---\n";
var_dump($people->person['age']);
var_dump(isset($people->person['age']));
$people->person['age'] = 30;
echo "---Unsupported---\n";
var_dump($people->person['age']);
$people->person['age'] += 5;
var_dump($people->person['age']);
?>
===DONE===
--EXPECTF--
object(SimpleXMLElement)#%d (1) {
  [0]=>
  string(3) "Joe"
}
NULL
object(SimpleXMLElement)#%d (1) {
  [0]=>
  string(3) "XXX"
}
object(SimpleXMLElement)#%d (1) {
  [0]=>
  string(2) "30"
}
---Unset:---
---Unset?---
NULL
bool(false)
---Unsupported---
object(SimpleXMLElement)#%d (1) {
  [0]=>
  string(2) "30"
}
object(SimpleXMLElement)#%d (1) {
  [0]=>
  string(2) "35"
}
===DONE===