![]() ![]() | ![]() |
1.1 misho 1: --TEST--
2: Test xml_parser_set_option() function : usage variations
3: --SKIPIF--
4: <?php
5: if (!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:
17: echo "*** Testing xml_parser_set_option() : usage variations ***\n";
18: error_reporting(E_ALL & ~E_NOTICE);
19:
20: class 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;
32: unset ($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:
92: foreach($values as $value) {
1.1.1.2 ! misho 93: echo @"\nArg value $value \n";
1.1 misho 94: var_dump( xml_parser_set_option($parser, $option, $value) );
95: };
96:
97: fclose($fp);
98: xml_parser_free($parser);
99: echo "Done";
100: ?>
101: --EXPECTF--
102: *** Testing xml_parser_set_option() : usage variations ***
103:
104: Arg value 0
105: bool(true)
106:
107: Arg value 1
108: bool(true)
109:
110: Arg value 12345
111: bool(true)
112:
113: Arg value -2345
114: bool(true)
115:
116: Arg value 10.5
117: bool(true)
118:
119: Arg value -10.5
120: bool(true)
121:
122: Arg value 101234567000
123: bool(true)
124:
125: Arg value 1.07654321E-9
126: bool(true)
127:
128: Arg value 0.5
129: bool(true)
130:
131: Arg value Array
132: bool(true)
133:
134: Arg value Array
135: bool(true)
136:
137: Arg value Array
138: bool(true)
139:
140: Arg value Array
141: bool(true)
142:
143: Arg value Array
144: bool(true)
145:
146: Arg value
147: bool(true)
148:
149: Arg value
150: bool(true)
151:
152: Arg value 1
153: bool(true)
154:
155: Arg value
156: bool(true)
157:
158: Arg value 1
159: bool(true)
160:
161: Arg value
162: bool(true)
163:
164: Arg value
165: bool(true)
166:
167: Arg value
168: bool(true)
169:
170: Arg value string
171: bool(true)
172:
173: Arg value string
174: bool(true)
175:
176: Arg value Some Ascii Data
177: bool(true)
178:
179: Arg value Resource id %s
180: bool(true)
181:
182: Arg value
183: bool(true)
184:
185: Arg value
186: bool(true)
187: Done