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));
26var_dump($first, $second, $third);
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
69string(1) "A"
70string(2) "%a"
71string(2) "%b"
72
73Test string with non-binary safe name
74NULL
75array(1) {
76  ["arr_test"]=>
77  array(2) {
78    [1]=>
79    string(3) "sid"
80    [4]=>
81    array(1) {
82      ["two"]=>
83      string(4) "fred"
84    }
85  }
86}
87===DONE===