It is not converted as having the query part of the URL after the fragment is not valid.
RFC 3986 defines a URI as composed of the following parts:
\_/ \______________/\_________/ \_________/ \__/
| | | | |
scheme authority path query fragment
will not. If we look at URL2, IE actually handles the URL properly by detecting the fragment as #ajax_call?query= without a query. Fragment is always last and are never sent to the server.
IE will properly encode the query component of URL1 as it will detect it as a query.
As for decoding in PHP, %D2 and similar is automatically decoded in the $_GET['query'] variable. The reason why the $_GET variable was not properly populated was because in URL2, there is no query according to the standard.
Also, one last thing... when doing '' == $_GET['query'], this will only be true if your PHP script itself is encoded in UTF-8. Your text editor should be able to tell you the encoding of your file.
Yes, indeed. Thank you for such a good reply. But it is a common practice to use fragment for ajax addresses. And it is a source of a problem, not a solution.
@topright: It is the solution. I'm not saying to drop the fragment all together, I'm saying that your fragment should always be last. Rewrite your links to respect that. PHP does not handle the query after the fragment as it does not expect it to the there (it's illegal according to RFC3986). IE does not even bother to try encoding it as it is expecting a fragment (which are limited to ASCII characters only).
is not send to the server
anything you put after # in the URL is never send to the server
Don't believe me? Try it out... echo $_SERVER['REQUEST_URI']; will give you exactly the request as seen by Apache. You'll quickly notice the fragment is missing. Also check your logs... There will be no fragment.