Using AND/OR in if else PHP statement

后端 未结 10 1931
梦如初夏
梦如初夏 2020-12-12 19:16

How do you use \'AND/OR\' in an if else PHP statement? Would it be:

1) AND

if ($status = \'clear\' AND $pRent == 0) {
    mysql_query(\"UPDATE rent 
         


        
10条回答
  •  旧时难觅i
    2020-12-12 20:22

    Yes. The answer is yes.
    http://www.php.net/manual/en/language.operators.logical.php


    Two things though:

    • Many programmers prefer && and || instead of and and or, but they work the same (safe for precedence).
    • $status = 'clear' should probably be $status == 'clear'. = is assignment, == is comparison.

提交回复
热议问题