1--TEST--
2mb_parse_str() with multiple candidate encodings
3--EXTENSIONS--
4mbstring
5--INI--
6mbstring.http_input=UTF-8,SJIS,EUC-JP,ISO-8859-1,ISO-2022-JP
7--FILE--
8<?php
9// The encoding of the input strings will be guessed, from the list specified
10// via mbstring.http_input
11// All of them will be converted to UTF-8
12mb_internal_encoding('UTF-8');
13
14$queries = array(
15  // UTF-8
16  "テスト=abc",
17  // SJIS
18  "\x82\xA0\x82\xA2\x82\xA4=\x93V",
19  "foo=\xE6&bar=\x97&baz=\xA5",
20  // invalid ISO-2022-JP
21  "a\x1F$(@=123",
22  "abc=a\x1F$(@"
23);
24
25foreach ($queries as $query) {
26  echo "Query: " . bin2hex($query) . "\n";
27
28  $array = [];
29  mb_parse_str($query, $array);
30
31  foreach ($array as $key => $value) {
32    echo bin2hex($key) . "=>" . bin2hex($value) . "\n";
33  }
34}
35
36?>
37--EXPECTF--
38Deprecated: PHP Startup: Use of mbstring.http_input is deprecated in %s on line %d
39Query: e38386e382b9e383883d616263
40e38386e382b9e38388=>616263
41Query: 82a082a282a43d9356
42e38182e38184e38186=>e5a4a9
43Query: 666f6f3de6266261723d972662617a3da5
44666f6f=>c3a6
45626172=>c297
4662617a=>c2a5
47Query: 611f2428403d313233
48611f242840=>313233
49Query: 6162633d611f242840
50616263=>611f242840
51