0
我有一个名为$user
的变量,它在URL中获取?u=
之后的值。有没有办法将当前页面的URL放入if语句中?
我想设置它是这样一个条件 - if the value after the ?u= in the URL is equal to $user, then do this ...
但我不知道,我怎么可以得到当前页面的URL。它甚至有可能吗?
我有一个名为$user
的变量,它在URL中获取?u=
之后的值。有没有办法将当前页面的URL放入if语句中?
我想设置它是这样一个条件 - if the value after the ?u= in the URL is equal to $user, then do this ...
但我不知道,我怎么可以得到当前页面的URL。它甚至有可能吗?
试试这个代码:
echo $_GET["u"];
$u=$_GET['u'];
if ($user==$u){
//Your Code
}
结帐[parse_url()](http://php.net/manual/en/function.parse-url.php),以获得关于URL信息,以及URL参数[$ _GET](http://php.net/manual/en/reserved.variables.get.php) –