我的if语句中出现意外的T_BOOLEAN_AND错误 [英] unexpected T_BOOLEAN_AND error in my if statement
本文介绍了我的if语句中出现意外的T_BOOLEAN_AND错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下IF语句:
if (strpos($_SERVER['REQUEST_URI'], '/dev/mahjong/mahjong.php') === strlen($_SERVER['REQUEST_URI']) - strlen('/dev/mahjong/mahjong.php') ) {
$style = "display: inline";
}
else {
$style = "display: none";
}
这个功能很好。现在我想在 $ style =display:inline;
This works great. Now I wanted to show a Facebook login screen when $style = "display:inline";
中显示一个Facebook登录屏幕,所以我想我使用AND进行另一个IF,所以如果display = inline AND user没有登录,请设置 $ fb_login =display:inline;
So I figured, I make another IF with an AND, so IF display = inline AND user is NOT logged in, set $fb_login = "display: inline";
我已经编写了这个代码:
I've cooked up this code:
if (strpos($_SERVER['REQUEST_URI'], '/dev/mahjong/mahjong.php') === strlen($_SERVER['REQUEST_URI']) - strlen('/dev/mahjong/mahjong.php') ) {
$style = "display: inline";
}
else {
$style = "display: none";
}
if ($style = "display: inline") && (!$user)) {
$fb_login = "display: inline";
}
else {
$fb_login = "display: none";
}
问题是我收到一个错误:解析错误: / strong>语法错误,意外的T_BOOLEAN_AND
Problem is I get an error with this: Parse error: syntax error, unexpected T_BOOLEAN_AND
还试图使用AND而不是& amp;&但是它得到了相同的结果。我在这里做错什么?
Also tried to use AND instead of && but it gave the same result. What am I doing wrong here?
推荐答案
- 你的赋值运算符(
=
)应该是一个比较运算符(==
) - 有一个不必要的括号(
)
- 我还删除了第二个条件下的一些不必要的括号。
- Your assignment operator (
=
) should be a comparison operator (==
) - There was an unneeded parenthesis (
)
) - I also removed some unnecessary brackets around the 2nd condition
if ($style == "display: inline" && !$user) {
$fb_login = "display: inline";
}
这篇关于我的if语句中出现意外的T_BOOLEAN_AND错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文