1--TEST--
2Test parse_str() function : test with badly formed strings
3--FILE--
4<?php
5/* Prototype  : void parse_str  ( string $str  [, array &$arr  ] )
6 * Description: Parses the string into variables
7 * Source code: ext/standard/string.c
8*/
9
10echo "\nTest string with badly formed strings\n";
11$str = "arr[1=sid&arr[4][2=fred";
12var_dump(parse_str($str, $res));
13var_dump($res);
14
15$str = "arr1]=sid&arr[4]2]=fred";
16var_dump(parse_str($str, $res));
17var_dump($res);
18
19$str = "arr[one=sid&arr[4][two=fred";
20var_dump(parse_str($str, $res));
21var_dump($res);
22
23echo "\nTest string with badly formed % numbers\n";
24$str = "first=%41&second=%a&third=%b";
25var_dump(parse_str($str, $res));
26var_dump($res);
27
28echo "\nTest string with non-binary safe name\n";
29$str = "arr.test[1]=sid&arr test[4][two]=fred";
30var_dump(parse_str($str, $res));
31var_dump($res);
32?>
33===DONE===
34--EXPECTF--
35Test string with badly formed strings
36NULL
37array(2) {
38  ["arr_1"]=>
39  string(3) "sid"
40  ["arr"]=>
41  array(1) {
42    [4]=>
43    string(4) "fred"
44  }
45}
46NULL
47array(2) {
48  ["arr1]"]=>
49  string(3) "sid"
50  ["arr"]=>
51  array(1) {
52    [4]=>
53    string(4) "fred"
54  }
55}
56NULL
57array(2) {
58  ["arr_one"]=>
59  string(3) "sid"
60  ["arr"]=>
61  array(1) {
62    [4]=>
63    string(4) "fred"
64  }
65}
66
67Test string with badly formed % numbers
68NULL
69array(3) {
70  ["first"]=>
71  string(1) "A"
72  ["second"]=>
73  string(2) "%a"
74  ["third"]=>
75  string(2) "%b"
76}
77
78Test string with non-binary safe name
79NULL
80array(1) {
81  ["arr_test"]=>
82  array(2) {
83    [1]=>
84    string(3) "sid"
85    [4]=>
86    array(1) {
87      ["two"]=>
88      string(4) "fred"
89    }
90  }
91}
92===DONE===
93