summaryrefslogtreecommitdiff
path: root/ext/simplexml/tests/033.phpt
blob: ba01b21555b0fb7349f74fdbaf71d3e49cfdc3c8 (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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
--TEST--
SimpleXML: casting instances
--SKIPIF--
<?php if (!extension_loaded("simplexml")) print "skip"; ?>
--FILE--
<?php

$xml =<<<EOF
<people>
test
  <person name="Joe"/>
  <person name="John">
    <children>
      <person name="Joe"/>
    </children>
  </person>
  <person name="Jane"/>
</people>
EOF;

$foo = simplexml_load_string( "<foo />" );
$people = simplexml_load_string($xml);

var_dump((bool)$foo);
var_dump((bool)$people);
var_dump((int)$foo);
var_dump((int)$people);
var_dump((double)$foo);
var_dump((double)$people);
var_dump((string)$foo);
var_dump((string)$people);
var_dump((array)$foo);
var_dump((array)$people);
var_dump((object)$foo);
var_dump((object)$people);

?>
===DONE===
--EXPECTF--
bool(false)
bool(true)
int(0)
int(0)
float(0)
float(0)
string(0) ""
string(15) "
test
  
  
  
"
array(0) {
}
array(1) {
  ["person"]=>
  array(3) {
    [0]=>
    object(SimpleXMLElement)#%d (1) {
      ["@attributes"]=>
      array(1) {
        ["name"]=>
        string(3) "Joe"
      }
    }
    [1]=>
    object(SimpleXMLElement)#%d (2) {
      ["@attributes"]=>
      array(1) {
        ["name"]=>
        string(4) "John"
      }
      ["children"]=>
      object(SimpleXMLElement)#%d (1) {
        ["person"]=>
        object(SimpleXMLElement)#%d (1) {
          ["@attributes"]=>
          array(1) {
            ["name"]=>
            string(3) "Joe"
          }
        }
      }
    }
    [2]=>
    object(SimpleXMLElement)#%d (1) {
      ["@attributes"]=>
      array(1) {
        ["name"]=>
        string(4) "Jane"
      }
    }
  }
}
object(SimpleXMLElement)#%d (0) {
}
object(SimpleXMLElement)#%d (1) {
  ["person"]=>
  array(3) {
    [0]=>
    object(SimpleXMLElement)#%d (1) {
      ["@attributes"]=>
      array(1) {
        ["name"]=>
        string(3) "Joe"
      }
    }
    [1]=>
    object(SimpleXMLElement)#%d (2) {
      ["@attributes"]=>
      array(1) {
        ["name"]=>
        string(4) "John"
      }
      ["children"]=>
      object(SimpleXMLElement)#%d (1) {
        ["person"]=>
        object(SimpleXMLElement)#%d (1) {
          ["@attributes"]=>
          array(1) {
            ["name"]=>
            string(3) "Joe"
          }
        }
      }
    }
    [2]=>
    object(SimpleXMLElement)#%d (1) {
      ["@attributes"]=>
      array(1) {
        ["name"]=>
        string(4) "Jane"
      }
    }
  }
}
===DONE===