0

When I use urlencode() on the same string containing special characters in PHP7 and PHP 5.3.10, the results are different.

What I tried:

urlencode('Testör')

Output in PHP7: Test%C3%B6r

Output in PHP 5.3: Test%25C3%25B6r

Could someone explain what the %25 leading in the older PHP version is?

2
  • 1
    Cannot replicate Commented Oct 2, 2017 at 10:23
  • 1
    @iainn I should have tested the actual result. Sorry for this. The question have been over simplified to be wrong. The actual differences seem to be in the handling of curl_setopt($ch, CURLOPT_URL, $url). Commented Oct 2, 2017 at 10:28

1 Answer 1

3

It looks to me that you've URL encoded it twice in the 5.3 output. %25 stands for %. Which is missing around the C3.

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

4 Comments

This could be the case. Actually I tried to use this within the url of a curl request. I used the same URL in curl_setopt($ch, CURLOPT_URL, $url) and then curl_getinfo($ch, CURLINFO_EFFECTIVE_URL) to see the differences with the same input string :/
What are the results?
I get these two results of PHP7 and PHP5.3 with the same code: http://192.168.1.1/update?name=file.zip&title=Test%C3%B6r http://192.168.1.1/update?name=file.zip&title=Test%25C3%25B6r I guess there are difference in the url handling of curl
I will check your answer as correct, as it is the correct answer... still have to research this odd default encoding ...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.