This question already has an answer here: The 3 different equals 4 answers 尝试这个 : <?php $page = ""; if(isset($_GET["page"]) && $_GET["page"] != "") { $page = $_GET["page"]; } ?> <div class="container"> <nav class="navbar navbar-inverse"> <div class="container-fluid"> <div class="navbar-header"> <a class="navbar-brand" h
这个问题在这里已经有了答案: 3个不同等于4个答案 尝试这个 : <?php $page = ""; if(isset($_GET["page"]) && $_GET["page"] != "") { $page = $_GET["page"]; } ?> <div class="container"> <nav class="navbar navbar-inverse"> <div class="container-fluid"> <div class="navbar-header"> <a class="navbar-brand" href="/womsy/home.php">Wo
Possible Duplicate: The 3 different equals Can anyone tell me why, when using the code below, I am getting redirected to elephant.com rather than seeing a 'giraffe! <?php $foo="giraffe"; if($foo="elephant"){ header("location:http://www.elephant.com"); exit(); }else{ echo $foo;} ?> Thanks for looking J if($foo="elephant") You're assigning $foo here, rather than comparing i
可能重复: 3个不同的等于 任何人都可以告诉我为什么,当使用下面的代码时,我被重定向到elephant.com,而不是看到'长颈鹿! <?php $foo="giraffe"; if($foo="elephant"){ header("location:http://www.elephant.com"); exit(); }else{ echo $foo;} ?> 感谢您的期待 Ĵ if($foo="elephant") 你在这里分配$foo ,而不是比较它; 你应该这样做: if($foo=="elephant") 赋值操作的结果是刚分配的值; 在这种
This question already has an answer here: The 3 different equals 4 answers $gameum['status'] = '0' // assigns the value '0' to $gamenum['status'] ($gameum['status'] == '0') // compares the two values Your if statement should be if($gameum['status'] == '0' ) { and if you are looking for strict check , i suggest you do if($gameum['status'] === '0' ) { Your are Assigning $gameum['stat
这个问题在这里已经有了答案: 3个不同等于4个答案 $gameum['status'] = '0' // assigns the value '0' to $gamenum['status'] ($gameum['status'] == '0') // compares the two values 你的if语句应该是 if($gameum['status'] == '0' ) { 如果你正在寻找strict检查,我建议你这样做 if($gameum['status'] === '0' ) { 你的是将$gameum['status']赋值$gameum['status'] 0 ,如果是条件语句,则添加do
This question already has an answer here: The 3 different equals 4 answers This is an assignment, and the expression returns bool(true) : if ($reg_as = "Exporter") To compare the two values, you should use two equal signs: if ($reg_as == "Exporter") Maybe your could do something like this: <form action="reg.php" method="post" enctype="multipart/form-data">
这个问题在这里已经有了答案: 3个不同等于4个答案 这是一个赋值,表达式返回bool(true) : if ($reg_as = "Exporter") 为了比较这两个值,你应该使用两个等号: if ($reg_as == "Exporter") 也许你可以做这样的事情: <form action="reg.php" method="post" enctype="multipart/form-data"> <select name="type" id="type"> <option value="importer">Importer&
This question already has an answer here: The 3 different equals 4 answers Here is your problem: if ($current == null || $current = "") { // ^ now `$current` is "", an empty string You assign a new value to $current , an empty string. You probably want something like: if ($current == null || $current == "") { // ^^ now you are c
这个问题在这里已经有了答案: 3个不同等于4个答案 这是你的问题: if ($current == null || $current = "") { // ^ now `$current` is "", an empty string 您将一个新值赋给$current ,一个空字符串。 你可能想要这样的东西: if ($current == null || $current == "") { // ^^ now you are comparing
This question already has an answer here: The 3 different equals 4 answers your if is not correct. You must use == , not = to check if somethng equals in PHP. if($user_post==5) You have to use comparison operator: equal == (same value) or identical === (same value and same type). You can explore php manual for learning http://php.net/manual/en/language.operators.comparison.php if($user_
这个问题在这里已经有了答案: 3个不同等于4个答案 你的if是不正确的。 您必须使用== ,not =来检查PHP中的somethng是否相等。 if($user_post==5) 你必须使用比较运算符:equal == (相同的值)或相同的=== (相同的值和相同的类型)。 您可以探索PHP手册以了解http://php.net/manual/en/language.operators.comparison.php if($user_post=5) 这是赋值运算符,每次它会分配5到$ user_post varibale来改变你的运算符 i
This question already has an answer here: The 3 different equals 4 answers $row["role"] = 1 this is assignment, not comparison. Go for $row["role"] == 1 you're using the OR operator (||), the operator verifies compliance any of the 2 conditions are indicating in the IF statement, for this reason will display the message: "You are a admin!" when any of the
这个问题在这里已经有了答案: 3个不同等于4个答案 $row["role"] = 1这是赋值,而不是比较。 去$row["role"] == 1 您正在使用OR运算符(||),运算符会验证符合条件的任何两个条件是否在IF语句中指示,因此,将显示消息:“您是管理员!” 当满足2个条件中的任何一个时。 如果您希望满足2个条件,则向您显示该消息必须使用逻辑AND(&&)来验证IF语句中两个条件的有效性。 if(isset($ _SE
This question already has an answer here: The 3 different equals 4 answers It prevents typos which cause very hard to debug bugs. That's in case you accidentally write = instead of == : if ($var == null) # This is true in case $var actually is null if ($var = null) # This will always be true, it will assign $var the value null Instead, switching them is safer: if (null == $var) #
这个问题在这里已经有了答案: 3个不同等于4个答案 它可以防止错误导致很难调试错误。 这是万一你不小心写=而不是== : if ($var == null) # This is true in case $var actually is null if ($var = null) # This will always be true, it will assign $var the value null 相反,切换它们更安全: if (null == $var) # True if $var is null if (null = $var) # This will raise compiler (or parser) error, a
This question already has an answer here: The 3 different equals 4 answers You are using = instead of == for the last cases. This will always be true since this is an assignation. Replace those by == and you're good to go. Careful with = and == . I think that is the problem. if ( $title == 'New York' ) { echo 'This is New York'; } elseif ( $title ==
这个问题在这里已经有了答案: 3个不同等于4个答案 您在最后一种情况下使用=而不是== 。 由于这是一项任务,因此这将始终如此。 用==代替这些,你很好。 小心使用=和==。 我认为这是问题。 if ( $title == 'New York' ) { echo 'This is New York'; } elseif ( $title == 'California' ) { echo 'This Is California'; } else if ($title == "Chica
Possible Duplicate: The 3 different equals Is there any difference between == and === in php? both seem to work fine for me when i use them in a conditional statement. I am very new to programming in PHP. Please consider this and answer in simple words. $a == $b Equal true : if $a is equal to $b , after type juggling. $a === $b Identical true : if $a is equal to $b , and they are o
可能重复: 3个不同的等于 在PHP和==之间有没有区别? 当我在条件语句中使用它们时,它们似乎都适用于我。 我对PHP编程非常陌生。 请考虑这一点,并用简单的话来回答。 $a == $b 同样如此 :如果$a等于$b ,那么在玩杂耍之后。 $a === $b 同样如此 :如果$a等于$b ,并且它们是相同的类型 。 相同: $a === $b 如果$a equal $b ,并且它们是相同类型, $b TRUE 。 (在PHP 4引入) 等于: $a == $b