开发者

php's $_SERVER['REQUEST_URI '] encoding problem?

开发者 https://www.devze.com 2022-12-08 21:33 出处:网络
When I output $_SERVER[\'REQUEST_URI\']; on: http://localhost/tools/?tool=cs&sub=1 I get: /tools/?tool=cs⊂=1

When I output $_SERVER['REQUEST_URI']; on:

http://localhost/tools/?tool=cs&sub=1

I get:

/tools/?tool=cs⊂=1

Is there开发者_Python百科 other solution to get /tools/?tool=cs&sub=1 besides using & instead of & ?


It's because you're echoing it to your browser - &sub is being interpreted as an HTML entity (⊂).

If you echo htmlentities($_SERVER['REQUEST_URI']); you'll get what you expect.

You have to use the right encoding for the environment you're in - in HTML that means using &.


try this

echo urldecode($_SERVER['REQUEST_URI']);


How are you outputting this value? If you're dumping it to the browser, are you sure it's not trying to 'decode' embedded ampersands?

Try a file with just

<?php phpinfo();

and look to see what the value is displayed as (near the bottom)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号