Annotation of embedaddon/php/ext/standard/tests/strings/parse_str_basic3.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test parse_str() function : basic functionality
3: --INI--
4: magic_quotes_gpc = on
5: --FILE--
6: <?php
7: /* Prototype : void parse_str ( string $str [, array &$arr ] )
8: * Description: Parses the string into variables
9: * Source code: ext/standard/string.c
10: */
11:
12: echo "*** Testing parse_str() : basic functionality ***\n";
13:
14: echo "\nTest string with array values\n";
15: $s1 = "first=abc&a[]=123&a[]=false&b[]=str&c[]=3.5&a[]=last";
16: var_dump(parse_str($s1));
17: var_dump($first, $a, $b, $c);
18:
19: echo "\nTest string with array values and results array\n";
20: $s1 = "first=abc&a[]=123&a[]=false&b[]=str&c[]=3.5&a[]=last";
21: var_dump(parse_str($s1, $res3_array));
22: var_dump($res3_array);
23:
24: echo "\nTest string containing numerical array keys\n";
25: $str = "arr[1]=sid&arr[4]=bill";
26: var_dump(parse_str($str, $res));
27: var_dump($res);
28:
29: echo "\nTest string containing associative keys\n";
30: $str = "arr[first]=sid&arr[forth]=bill";
31: var_dump(parse_str($str, $res));
32: var_dump($res);
33:
34: echo "\nTest string with array values with same name as existing variable\n";
35: $a = 9999;
36: $s1 = "a[]=123&a[]=false&a[]=last";
37: var_dump(parse_str($s1));
38: var_dump($a);
39:
40: echo "\nTest string with non-array value with same name as existing array variable\n";
41: $a = array(10,11,12,13);
42: $s1 = "a=999";
43: parse_str($s1);
44: var_dump($a);
45:
46: echo "\nTest string with encoded data\n";
47: $s1 = "a=%3c%3d%3d%20%20foo+bar++%3d%3d%3e&b=%23%23%23Hello+World%23%23%23";
48: parse_str($s1);
49: var_dump($a, $b);
50:
51: echo "\nTest string with single quotes characters\n";
52: $s1 = "firstname=Bill&surname=O%27Reilly";
53: var_dump(parse_str($s1));
54: var_dump($firstname, $surname);
55:
56: echo "\nTest string with backslash characters\n";
57: $s1 = "sum=10%5c2%3d5";
58: var_dump(parse_str($s1));
59: var_dump($sum);
60:
61: echo "\nTest string with double quotes data\n";
62: $s1 = "str=A+string+with+%22quoted%22+strings";
63: var_dump(parse_str($s1));
64: var_dump($str);
65:
66: echo "\nTest string with nulls\n";
67: $s1 = "str=A%20string%20with%20containing%20%00%00%00%20nulls";
68: var_dump(parse_str($s1));
69: var_dump($str);
70:
71: echo "\nTest string with 2-dim array with numeric keys\n";
72: $str = "arr[3][4]=sid&arr[3][6]=fred";
73: var_dump(parse_str($str, $res));
74: var_dump($res);
75:
76: echo "\nTest string with 2-dim array with null keys\n";
77: $str = "arr[][]=sid&arr[][]=fred";
78: var_dump(parse_str($str, $res));
79: var_dump($res);
80:
81: echo "\nTest string with 2-dim array with non-numeric keys\n";
82: $str = "arr[one][four]=sid&arr[three][six]=fred";
83: var_dump(parse_str($str, $res));
84: var_dump($res);
85:
86: echo "\nTest string with 3-dim array with numeric keys\n";
87: $str = "arr[1][2][3]=sid&arr[1][2][6]=fred";
88: var_dump(parse_str($str, $res));
89: var_dump($res);
90:
91: ?>
92: ===DONE===
93: --EXPECTF--
94: Deprecated: Directive 'magic_quotes_gpc' is deprecated in PHP 5.3 and greater in Unknown on line 0
95: *** Testing parse_str() : basic functionality ***
96:
97: Test string with array values
98: NULL
99: string(3) "abc"
100: array(3) {
101: [0]=>
102: string(3) "123"
103: [1]=>
104: string(5) "false"
105: [2]=>
106: string(4) "last"
107: }
108: array(1) {
109: [0]=>
110: string(3) "str"
111: }
112: array(1) {
113: [0]=>
114: string(3) "3.5"
115: }
116:
117: Test string with array values and results array
118: NULL
119: array(4) {
120: ["first"]=>
121: string(3) "abc"
122: ["a"]=>
123: array(3) {
124: [0]=>
125: string(3) "123"
126: [1]=>
127: string(5) "false"
128: [2]=>
129: string(4) "last"
130: }
131: ["b"]=>
132: array(1) {
133: [0]=>
134: string(3) "str"
135: }
136: ["c"]=>
137: array(1) {
138: [0]=>
139: string(3) "3.5"
140: }
141: }
142:
143: Test string containing numerical array keys
144: NULL
145: array(1) {
146: ["arr"]=>
147: array(2) {
148: [1]=>
149: string(3) "sid"
150: [4]=>
151: string(4) "bill"
152: }
153: }
154:
155: Test string containing associative keys
156: NULL
157: array(1) {
158: ["arr"]=>
159: array(2) {
160: ["first"]=>
161: string(3) "sid"
162: ["forth"]=>
163: string(4) "bill"
164: }
165: }
166:
167: Test string with array values with same name as existing variable
168: NULL
169: array(3) {
170: [0]=>
171: string(3) "123"
172: [1]=>
173: string(5) "false"
174: [2]=>
175: string(4) "last"
176: }
177:
178: Test string with non-array value with same name as existing array variable
179: string(3) "999"
180:
181: Test string with encoded data
182: string(17) "<== foo bar ==>"
183: string(17) "###Hello World###"
184:
185: Test string with single quotes characters
186: NULL
187: string(4) "Bill"
188: string(9) "O\'Reilly"
189:
190: Test string with backslash characters
191: NULL
192: string(7) "10\\2=5"
193:
194: Test string with double quotes data
195: NULL
196: string(32) "A string with \"quoted\" strings"
197:
198: Test string with nulls
199: NULL
200: string(37) "A string with containing \0\0\0 nulls"
201:
202: Test string with 2-dim array with numeric keys
203: NULL
204: array(1) {
205: ["arr"]=>
206: array(1) {
207: [3]=>
208: array(2) {
209: [4]=>
210: string(3) "sid"
211: [6]=>
212: string(4) "fred"
213: }
214: }
215: }
216:
217: Test string with 2-dim array with null keys
218: NULL
219: array(1) {
220: ["arr"]=>
221: array(2) {
222: [0]=>
223: array(1) {
224: [0]=>
225: string(3) "sid"
226: }
227: [1]=>
228: array(1) {
229: [0]=>
230: string(4) "fred"
231: }
232: }
233: }
234:
235: Test string with 2-dim array with non-numeric keys
236: NULL
237: array(1) {
238: ["arr"]=>
239: array(2) {
240: ["one"]=>
241: array(1) {
242: ["four"]=>
243: string(3) "sid"
244: }
245: ["three"]=>
246: array(1) {
247: ["six"]=>
248: string(4) "fred"
249: }
250: }
251: }
252:
253: Test string with 3-dim array with numeric keys
254: NULL
255: array(1) {
256: ["arr"]=>
257: array(1) {
258: [1]=>
259: array(1) {
260: [2]=>
261: array(2) {
262: [3]=>
263: string(3) "sid"
264: [6]=>
265: string(4) "fred"
266: }
267: }
268: }
269: }
270: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>