mb_parse_str.phpt 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. --TEST--
  2. mb_parse_str()
  3. --SKIPIF--
  4. <?php extension_loaded('mbstring') or die('skip mbstring not available'); ?>
  5. --FAIL--
  6. register_globals calls killed the ability for mb_parse_str() to register into the global scope
  7. --INI--
  8. arg_separator.input=&
  9. --FILE--
  10. <?php
  11. $queries = array(
  12. "foo=abc&bar=def",
  13. "%2bfoo=def&-bar=jkl",
  14. "foo[]=abc&foo[]=def&foo[]=ghi&bar[]=jkl"
  15. );
  16. function test($query) {
  17. $foo = '';
  18. $bar = '';
  19. mb_parse_str($query, $array);
  20. var_dump($array);
  21. var_dump($foo);
  22. var_dump($bar);
  23. mb_parse_str($query);
  24. var_dump($foo);
  25. var_dump($bar);
  26. }
  27. foreach ($queries as $query) {
  28. test($query);
  29. }
  30. ?>
  31. --EXPECT--
  32. array(2) {
  33. ["foo"]=>
  34. string(3) "abc"
  35. ["bar"]=>
  36. string(3) "def"
  37. }
  38. string(0) ""
  39. string(0) ""
  40. string(3) "abc"
  41. string(3) "def"
  42. array(2) {
  43. ["+foo"]=>
  44. string(3) "def"
  45. ["-bar"]=>
  46. string(3) "jkl"
  47. }
  48. string(0) ""
  49. string(0) ""
  50. string(0) ""
  51. string(0) ""
  52. array(2) {
  53. ["foo"]=>
  54. array(3) {
  55. [0]=>
  56. string(3) "abc"
  57. [1]=>
  58. string(3) "def"
  59. [2]=>
  60. string(3) "ghi"
  61. }
  62. ["bar"]=>
  63. array(1) {
  64. [0]=>
  65. string(3) "jkl"
  66. }
  67. }
  68. string(0) ""
  69. string(0) ""
  70. array(3) {
  71. [0]=>
  72. string(3) "abc"
  73. [1]=>
  74. string(3) "def"
  75. [2]=>
  76. string(3) "ghi"
  77. }
  78. array(1) {
  79. [0]=>
  80. string(3) "jkl"
  81. }