我有:http://www.example.com/index.php?amount=15%252E8
在索引中.php:
$test = $_GET['amount'];
echo $test;
// Output: 15%2E8
但我不需要 15%2E8,我需要 15.8
$test = $_GET['amount'];
$test = urldecode($test);
echo $test;
//Output: 15.8
但在 http://us2.php.net/manual/en/function.urldecode.php 他们警告说:
警告:超全局变量 $_GET 和 $_REQUEST 已被解码。 在 $_GET 或 $_REQUEST 中的元素上使用 urldecode() 可以有 意想不到和危险的结果。
为什么 $_GET["金额"] 没有得到 15.8 ?!
15%252E8
是"15%2E8"的URL编码版本。
15%2E8
是"15.8"的 URL 编码版本。
如果你想要"15.8",你应该在URL中发送15%2E8
。
即您在某处进行 URL 编码一次太多。