PHP:在url $ _GET urldecode中编码解码点

时间:2013-10-30 13:54:38

标签: php url urldecode

我有: http://www.example.com/index.php?amount=15%252E8

在index.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 ?!

1 个答案:

答案 0 :(得分:4)

15%252E8是“15%2E8”的网址编码版本 15%2E8是“15.8”的网址编码版本 如果您想要“15.8”,则应在网址中发送15%2E8

即。你在某个地方进行了一次URL编码。

相关问题