我总是通过 $_SERVER['QUERY_STRING'] 或 $_SERVER['REQUEST_URI'] 获取查询字符串和路径,但有时会得到无效值,
#1
?a[]=1&b[]=2
(should be: ?a%5B%5D=1&b%5B%5D=2)
#2
?c%5B%5D=3&d[]=4
(should be: ?c%5B%5D=3&d%5B%5D=4)
#3
/to/path*/a/1
(should be: /to/path%2A/a/1)
#4
/to/path%2A/a*/1
(should be: /to/path%2A/a%2A/1)
我如何始终获得已编码的字符串?如果使用 urlencode() 是个坏主意,因为某些字符已被编码或不应该被编码。