有没有办法将当前页面URL放在if语句中?

时间:2016-03-05 15:45:23

标签: php

我有一个名为$user的变量,它获取URL中?u=之后的值。

我试图设置一个类似这样的条件 - if the value after the ?u= in the URL is equal to $user, then do this ...

但我不知道如何获取当前页面网址。它甚至可能吗?

4 个答案:

答案 0 :(得分:1)

if(isset($_GET['u']){
   //Making sure that variable is set, otherwise while getting it return error
   $url = $_GET['u'];
   if ($user == $url){
       //Your Code
   }
}

答案 1 :(得分:0)

试试这段代码:

if($blabla == ""){...

答案 2 :(得分:0)

$u=$_GET['u'];
if ($user==$u){
//Your Code
}

答案 3 :(得分:0)

您可以尝试使用此代码

<?php 
if($user == $_REQUEST['u']){
 echo 'condition true';
}
?>