php's $_SERVER['REQUEST_URI '] encoding problem?
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)
精彩评论