$_SERVER['QUERY_STRING'] does not print unicode values as it is

前端 未结 2 1561
故里飘歌
故里飘歌 2021-01-26 08:07

http://localhost/fw/api/fw_api.php?rule=unicode&action=create&phrase=යුනිකෝඩ්

I accessing the above url. In fw_api.php, when I echo the

2条回答
  •  旧时难觅i
    2021-01-26 09:01

    The actual value is actually "%E0%B6%BA%E0%B7%94%E0..."!

    URLs must consist of a subset of ASCII, they cannot contain other "Unicode characters". Your browser may be so nice as to let you input arbitrary Unicode characters and actually display them as characters, but behind the scenes the URL value is percent encoded. You'll have to decode it with rawurldecode.

    The query string is automatically being parsed and decoded by PHP and placed in the $_GET array (and $_POST for the request body). But the raw query string you'll have to parse and decode yourself.

提交回复
热议问题