how do you copy a url into variable
I'm trying to copy a url that looks like this: http://domain.com/myfile.php?test-main
So I'm trying to get the url so I can add variable r to the end like so: http://domain.com/myfile.php?test-main?r=stuff
When I use $_SERVER['REQUEST_URI']
it just copies the file name myfile.php and not the other variables. Any one how I can copy the entire url?
$addr = "http://".$_SERVER['SERVER_NAME']."/".$_SERVER['REQUEST_URI']."?".$_SERVER['QUERY_STRING']."&r=stuff";
And you might want to filter variables for a possible XSS attack
Build it yourself out of the provided parts.
Do a print_r($_SERVER); to see all available
The main one you want to add is HTTP_HOST
精彩评论