开发者

How can i get the Querystring from URL?

开发者 https://www.devze.com 2023-03-09 17:33 出处:网络
Hi I have URl like below http://word.dev.net/apps/website-management?affiliate=true 开发者_如何学C

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.

0

精彩评论

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