1--TEST--
2Test xml_parser_create_ns() function : usage variations
3--SKIPIF--
4<?php
5if (!extension_loaded("xml")) {
6	print "skip - XML extension not loaded";
7}
8?>
9--FILE--
10<?php
11/* Prototype  : proto resource xml_parser_create_ns([string encoding [, string sep]])
12 * Description: Create an XML parser
13 * Source code: ext/xml/xml.c
14 * Alias to functions:
15 */
16
17echo "*** Testing xml_parser_create_ns() : usage variations ***\n";
18error_reporting(E_ALL & ~E_NOTICE);
19
20class aClass {
21   function __toString() {
22       return "Some Ascii Data";
23   }
24}
25// Initialise function arguments not being substituted (if any)
26
27//get an unset variable
28$unset_var = 10;
29unset ($unset_var);
30
31$fp = fopen(__FILE__, "r");
32
33//array of values to iterate over
34$values = array(
35
36      // int data
37      0,
38      1,
39      12345,
40      -2345,
41
42      // float data
43      10.5,
44      -10.5,
45      10.1234567e10,
46      10.7654321E-10,
47      .5,
48
49      // array data
50      array(),
51      array(0),
52      array(1),
53      array(1, 2),
54      array('color' => 'red', 'item' => 'pen'),
55
56      // null data
57      NULL,
58      null,
59
60      // boolean data
61      true,
62      false,
63      TRUE,
64      FALSE,
65
66      // empty data
67      "",
68      '',
69
70      // string data
71      "string",
72      'string',
73      "ISO-8859-1",
74      "UTF-8",
75      "US-ASCII",
76      "UTF-32",
77
78      // object data
79      new aClass(),
80
81      // resource data
82      $fp,
83
84      // undefined data
85      $undefined_var,
86
87      // unset data
88      $unset_var,
89);
90
91// loop through each element of the array for encoding
92
93foreach($values as $value) {
94      echo @"\nArg value $value \n";
95      $res = xml_parser_create_ns($value);
96      var_dump($res);
97      if ($res !== false) {
98         xml_parser_free($res);
99      }
100};
101
102fclose($fp);
103echo "Done";
104?>
105--EXPECTF--
106*** Testing xml_parser_create_ns() : usage variations ***
107
108Arg value 0
109
110Warning: xml_parser_create_ns(): unsupported source encoding "0" in %s on line %d
111bool(false)
112
113Arg value 1
114
115Warning: xml_parser_create_ns(): unsupported source encoding "1" in %s on line %d
116bool(false)
117
118Arg value 12345
119
120Warning: xml_parser_create_ns(): unsupported source encoding "12345" in %s on line %d
121bool(false)
122
123Arg value -2345
124
125Warning: xml_parser_create_ns(): unsupported source encoding "-2345" in %s on line %d
126bool(false)
127
128Arg value 10.5
129
130Warning: xml_parser_create_ns(): unsupported source encoding "10.5" in %s on line %d
131bool(false)
132
133Arg value -10.5
134
135Warning: xml_parser_create_ns(): unsupported source encoding "-10.5" in %s on line %d
136bool(false)
137
138Arg value 101234567000
139
140Warning: xml_parser_create_ns(): unsupported source encoding "101234567000" in %s on line %d
141bool(false)
142
143Arg value 1.07654321E-9
144
145Warning: xml_parser_create_ns(): unsupported source encoding "1.07654321E-9" in %s on line %d
146bool(false)
147
148Arg value 0.5
149
150Warning: xml_parser_create_ns(): unsupported source encoding "0.5" in %s on line %d
151bool(false)
152
153Arg value Array
154
155Warning: xml_parser_create_ns() expects parameter 1 to be string, array given in %s on line %d
156bool(false)
157
158Arg value Array
159
160Warning: xml_parser_create_ns() expects parameter 1 to be string, array given in %s on line %d
161bool(false)
162
163Arg value Array
164
165Warning: xml_parser_create_ns() expects parameter 1 to be string, array given in %s on line %d
166bool(false)
167
168Arg value Array
169
170Warning: xml_parser_create_ns() expects parameter 1 to be string, array given in %s on line %d
171bool(false)
172
173Arg value Array
174
175Warning: xml_parser_create_ns() expects parameter 1 to be string, array given in %s on line %d
176bool(false)
177
178Arg value
179resource(%d) of type (xml)
180
181Arg value
182resource(%d) of type (xml)
183
184Arg value 1
185
186Warning: xml_parser_create_ns(): unsupported source encoding "1" in %s on line %d
187bool(false)
188
189Arg value
190resource(%d) of type (xml)
191
192Arg value 1
193
194Warning: xml_parser_create_ns(): unsupported source encoding "1" in %s on line %d
195bool(false)
196
197Arg value
198resource(%d) of type (xml)
199
200Arg value
201resource(%d) of type (xml)
202
203Arg value
204resource(%d) of type (xml)
205
206Arg value string
207
208Warning: xml_parser_create_ns(): unsupported source encoding "string" in %s on line %d
209bool(false)
210
211Arg value string
212
213Warning: xml_parser_create_ns(): unsupported source encoding "string" in %s on line %d
214bool(false)
215
216Arg value ISO-8859-1
217resource(%d) of type (xml)
218
219Arg value UTF-8
220resource(%d) of type (xml)
221
222Arg value US-ASCII
223resource(%d) of type (xml)
224
225Arg value UTF-32
226
227Warning: xml_parser_create_ns(): unsupported source encoding "UTF-32" in %s on line %d
228bool(false)
229
230Arg value Some Ascii Data
231
232Warning: xml_parser_create_ns(): unsupported source encoding "Some Ascii Data" in %s on line %d
233bool(false)
234
235Arg value Resource id %s
236
237Warning: xml_parser_create_ns() expects parameter 1 to be string, resource given in %s on line %d
238bool(false)
239
240Arg value
241resource(%d) of type (xml)
242
243Arg value
244resource(%d) of type (xml)
245Done
246