1--TEST--
2Test xml_parser_get_option() 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 int xml_parser_get_option(resource parser, int option)
12 * Description: Get options from an XML parser
13 * Source code: ext/xml/xml.c
14 * Alias to functions:
15 */
16
17echo "*** Testing xml_parser_get_option() : 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$parser = xml_parser_create();
27
28//get an unset variable
29$unset_var = 10;
30unset ($unset_var);
31
32$fp = fopen(__FILE__, "r");
33
34//array of values to iterate over
35$values = array(
36
37      // outside of range int data
38      12345,
39      -2345,
40
41      // float data
42      10.5,
43      -10.5,
44      10.1234567e10,
45      10.7654321E-10,
46      .5,
47
48      // array data
49      array(),
50      array(0),
51      array(1),
52      array(1, 2),
53      array('color' => 'red', 'item' => 'pen'),
54
55      // null data
56      NULL,
57      null,
58
59      // boolean data
60      true,
61      false,
62      TRUE,
63      FALSE,
64
65      // empty data
66      "",
67      '',
68
69      // string data
70      "string",
71      'string',
72
73      // object data
74      new aClass(),
75
76      // resource data
77      $fp,
78
79      // undefined data
80      $undefined_var,
81
82      // unset data
83      $unset_var,
84);
85
86// loop through each element of the array for option
87
88foreach($values as $value) {
89      echo @"\nArg value $value \n";
90      var_dump( xml_parser_get_option($parser, $value) );
91};
92
93fclose($fp);
94xml_parser_free($parser);
95echo "Done";
96?>
97--EXPECTF--
98*** Testing xml_parser_get_option() : usage variations ***
99
100Arg value 12345
101
102Warning: xml_parser_get_option(): Unknown option in %s on line %d
103bool(false)
104
105Arg value -2345
106
107Warning: xml_parser_get_option(): Unknown option in %s on line %d
108bool(false)
109
110Arg value 10.5
111
112Warning: xml_parser_get_option(): Unknown option in %s on line %d
113bool(false)
114
115Arg value -10.5
116
117Warning: xml_parser_get_option(): Unknown option in %s on line %d
118bool(false)
119
120Arg value 101234567000
121
122Warning: xml_parser_get_option(): Unknown option in %s on line %d
123bool(false)
124
125Arg value 1.07654321E-9
126
127Warning: xml_parser_get_option(): Unknown option in %s on line %d
128bool(false)
129
130Arg value 0.5
131
132Warning: xml_parser_get_option(): Unknown option in %s on line %d
133bool(false)
134
135Arg value Array
136
137Warning: xml_parser_get_option() expects parameter 2 to be long, array given in %s on line %d
138NULL
139
140Arg value Array
141
142Warning: xml_parser_get_option() expects parameter 2 to be long, array given in %s on line %d
143NULL
144
145Arg value Array
146
147Warning: xml_parser_get_option() expects parameter 2 to be long, array given in %s on line %d
148NULL
149
150Arg value Array
151
152Warning: xml_parser_get_option() expects parameter 2 to be long, array given in %s on line %d
153NULL
154
155Arg value Array
156
157Warning: xml_parser_get_option() expects parameter 2 to be long, array given in %s on line %d
158NULL
159
160Arg value
161
162Warning: xml_parser_get_option(): Unknown option in %s on line %d
163bool(false)
164
165Arg value
166
167Warning: xml_parser_get_option(): Unknown option in %s on line %d
168bool(false)
169
170Arg value 1
171int(1)
172
173Arg value
174
175Warning: xml_parser_get_option(): Unknown option in %s on line %d
176bool(false)
177
178Arg value 1
179int(1)
180
181Arg value
182
183Warning: xml_parser_get_option(): Unknown option in %s on line %d
184bool(false)
185
186Arg value
187
188Warning: xml_parser_get_option() expects parameter 2 to be long, string given in %s on line %d
189NULL
190
191Arg value
192
193Warning: xml_parser_get_option() expects parameter 2 to be long, string given in %s on line %d
194NULL
195
196Arg value string
197
198Warning: xml_parser_get_option() expects parameter 2 to be long, string given in %s on line %d
199NULL
200
201Arg value string
202
203Warning: xml_parser_get_option() expects parameter 2 to be long, string given in %s on line %d
204NULL
205
206Arg value Some Ascii Data
207
208Warning: xml_parser_get_option() expects parameter 2 to be long, object given in %s on line %d
209NULL
210
211Arg value Resource id %s
212
213Warning: xml_parser_get_option() expects parameter 2 to be long, resource given in %s on line %d
214NULL
215
216Arg value
217
218Warning: xml_parser_get_option(): Unknown option in %s on line %d
219bool(false)
220
221Arg value
222
223Warning: xml_parser_get_option(): Unknown option in %s on line %d
224bool(false)
225Done
226
227