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