File tree Expand file tree Collapse file tree 2 files changed +182
-0
lines changed Expand file tree Collapse file tree 2 files changed +182
-0
lines changed Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ SimpleXML: comparing instances
3
+ --SKIPIF--
4
+ <?php if (!extension_loaded ("simplexml " )) print "skip " ; ?>
5
+ --FILE--
6
+ <?php
7
+ $ xml =<<<EOF
8
+ <people>
9
+ <person name="Joe"/>
10
+ <person name="John">
11
+ <children>
12
+ <person name="Joe"/>
13
+ </children>
14
+ </person>
15
+ <person name="Jane"/>
16
+ </people>
17
+ EOF ;
18
+
19
+ $ xml1 =<<<EOF
20
+ <people>
21
+ <person name="John">
22
+ <children>
23
+ <person name="Joe"/>
24
+ </children>
25
+ </person>
26
+ <person name="Jane"/>
27
+ </people>
28
+ EOF ;
29
+
30
+
31
+ $ people = simplexml_load_string ($ xml );
32
+ $ people1 = simplexml_load_string ($ xml );
33
+ $ people2 = simplexml_load_string ($ xml1 );
34
+
35
+ var_dump ($ people1 == $ people );
36
+ var_dump ($ people2 == $ people );
37
+ var_dump ($ people2 == $ people1 );
38
+
39
+ ?>
40
+ ===DONE===
41
+ --EXPECTF--
42
+ bool(true)
43
+ bool(false)
44
+ bool(false)
45
+ ===DONE===
Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ SimpleXML: casting instances
3
+ --SKIPIF--
4
+ <?php if (!extension_loaded ("simplexml " )) print "skip " ; ?>
5
+ --FILE--
6
+ <?php
7
+
8
+ $ xml =<<<EOF
9
+ <people>
10
+ test
11
+ <person name="Joe"/>
12
+ <person name="John">
13
+ <children>
14
+ <person name="Joe"/>
15
+ </children>
16
+ </person>
17
+ <person name="Jane"/>
18
+ </people>
19
+ EOF ;
20
+
21
+ $ foo = simplexml_load_string ( "<foo /> " );
22
+ $ people = simplexml_load_string ($ xml );
23
+
24
+ var_dump ((bool )$ foo );
25
+ var_dump ((bool )$ people );
26
+ var_dump ((int )$ foo );
27
+ var_dump ((int )$ people );
28
+ var_dump ((double )$ foo );
29
+ var_dump ((double )$ people );
30
+ var_dump ((string )$ foo );
31
+ var_dump ((string )$ people );
32
+ var_dump ((array )$ foo );
33
+ var_dump ((array )$ people );
34
+ var_dump ((object )$ foo );
35
+ var_dump ((object )$ people );
36
+
37
+ ?>
38
+ ===DONE===
39
+ --EXPECTF--
40
+ bool(false)
41
+ bool(true)
42
+ int(0)
43
+ int(0)
44
+ float(0)
45
+ float(0)
46
+ string(0) ""
47
+ string(15) "
48
+ test
49
+
50
+
51
+
52
+ "
53
+ array(0) {
54
+ }
55
+ array(1) {
56
+ ["person"]=>
57
+ array(3) {
58
+ [0]=>
59
+ object(SimpleXMLElement)#%d (1) {
60
+ ["@attributes"]=>
61
+ array(1) {
62
+ ["name"]=>
63
+ string(3) "Joe"
64
+ }
65
+ }
66
+ [1]=>
67
+ object(SimpleXMLElement)#%d (2) {
68
+ ["@attributes"]=>
69
+ array(1) {
70
+ ["name"]=>
71
+ string(4) "John"
72
+ }
73
+ ["children"]=>
74
+ object(SimpleXMLElement)#%d (1) {
75
+ ["person"]=>
76
+ object(SimpleXMLElement)#%d (1) {
77
+ ["@attributes"]=>
78
+ array(1) {
79
+ ["name"]=>
80
+ string(3) "Joe"
81
+ }
82
+ }
83
+ }
84
+ }
85
+ [2]=>
86
+ object(SimpleXMLElement)#%d (1) {
87
+ ["@attributes"]=>
88
+ array(1) {
89
+ ["name"]=>
90
+ string(4) "Jane"
91
+ }
92
+ }
93
+ }
94
+ }
95
+ object(SimpleXMLElement)#%d (0) {
96
+ }
97
+ object(SimpleXMLElement)#%d (1) {
98
+ ["person"]=>
99
+ array(3) {
100
+ [0]=>
101
+ object(SimpleXMLElement)#%d (1) {
102
+ ["@attributes"]=>
103
+ array(1) {
104
+ ["name"]=>
105
+ string(3) "Joe"
106
+ }
107
+ }
108
+ [1]=>
109
+ object(SimpleXMLElement)#%d (2) {
110
+ ["@attributes"]=>
111
+ array(1) {
112
+ ["name"]=>
113
+ string(4) "John"
114
+ }
115
+ ["children"]=>
116
+ object(SimpleXMLElement)#%d (1) {
117
+ ["person"]=>
118
+ object(SimpleXMLElement)#%d (1) {
119
+ ["@attributes"]=>
120
+ array(1) {
121
+ ["name"]=>
122
+ string(3) "Joe"
123
+ }
124
+ }
125
+ }
126
+ }
127
+ [2]=>
128
+ object(SimpleXMLElement)#%d (1) {
129
+ ["@attributes"]=>
130
+ array(1) {
131
+ ["name"]=>
132
+ string(4) "Jane"
133
+ }
134
+ }
135
+ }
136
+ }
137
+ ===DONE===
You can’t perform that action at this time.
0 commit comments