0

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

In index.php:

    $test = $_GET['amount'];
    echo $test; 

    // Output: 15%2E8

But I don't need 15%2E8, I need 15.8

    $test = $_GET['amount'];
    $test = urldecode($test);
    echo $test; 
    
    //Output: 15.8

But in https://www.php.net/manual/en/function.urldecode.php they warn:

Warning: The superglobals $_GET and $_REQUEST are already decoded. Using urldecode() on an element in $_GET or $_REQUEST could have unexpected and dangerous results.

Why $_GET['amount'] does not get 15.8 ?!

2
  • What is the value that you send in 'amount' Commented Oct 30, 2013 at 13:56
  • You're url example shows 15%252E8 but your Output example shows 15%2E8. Is this a typo or is it really dropping off the '25' in the middle? Commented Oct 30, 2013 at 17:58

1 Answer 1

4

15%252E8 is the URL encoded version of "15%2E8".
15%2E8 is the URL encoded version of "15.8".
If you want "15.8", you should be sending 15%2E8 in the URL.

I.e. you're URL-encoding one time too many somewhere.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.