'PHP $_SERVER['REQUEST_URI'] returns question marks ? for utf-8 characters after the slash
I have a route.php which gets called for every php request to return a friendly uri.
In route.php it parses $_SERVER['REQUEST_URI'] to get the parameters. I have a problem now when the request uri contains utf-8 characters after the slash, it will become question marks.
For example this request work well, http://localhost/route.php/testing
$_SERVER['REQUEST_URI'] return /route.php/testing
but this does not work, http://localhost/route.php/良い
$_SERVER['REQUEST_URI'] return /route.php/??
Is there a way to get the parameters correctly?
Solution 1:[1]
Try to encode the characters, like so:
mb_convert_encode($_SERVER['REQUEST_URI'],'HTML-ENTITIES','UTF-8');
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
