Hi I have URl like below
http://word.dev.net/apps/website-management?affiliate=true
开发者_如何学C
now I am using $_SERVER['REQUEST_URI']
for getting current url. what I need to do to get the string affiliate=true
alone?.. please help me.
You are looking for
$_SERVER["QUERY_STRING"]
You can find all (usually) predefined variables in PHP here.
What often helps is doing a phpinfo()
that will list all environment and other variables that are currently set.
That is called a GET variable, and you can acces it via the global variable
$_GET['affiliate']
So in your code you would do something like:
if(isset($_GET['affiliate']))
/*do something with the var*/
or if you are really interested in just the string itself you can access it using the
$_SERVER["QUERY_STRING"]
global variable
You can combine $_SERVER['QUERY_STRING']
with parse_url
function in PHP (http://php.net/manual/en/function.parse-url.php) to get the url components.
精彩评论