我想在用户登录时显示一条消息:
If the data is correct I will create the user session and other session named CORRECT
and then check if this session exist for show the correct message:
首先,我创建会话:
$_SESSION['CORRECT'] = true;
现在我检查:
if($_SESSION['CORRECT']){
echo = "Correct";
$_SESSION['CORRECT'] = false;
}else{
echo = "Incorrect";
}
我的问题是,会话验证是否正确?还是应该这样检查?:
if($_SESSION['CORRECT'] == true)
1:
if($_SESSION['CORRECT']){}
2:
if($_SESSION['CORRECT'] == true){}
两者均可用于检查,但它们的用途不同
if($_SESSION['CORRECT']){}
will check thatif($_SESSION['CORRECT']){}
is present in the code or not andif($_SESSION['CORRECT'] == true){}
will check whether the value of$_SESSION['CORRECT']
is equal to true.