note 24511 deleted from control-structures by didou

From: Date: Mon, 04 Aug 2003 06:03:30 +0000
Subject: note 24511 deleted from control-structures by didou
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-53301@lists.php.net to get a copy of this message
Note Submitter: simon@invalid.com ---- There are something to remind beginners: if(-1) echo "(-1 OK) "; else echo "(-1 fail) "; if("") echo "(\"\" OK) "; else echo "(\"\" fail) "; if(0) echo "(0 OK) "; else echo "(0 fail) "; // result: (-1 OK) ("" fail) (0 fail) In addition, if you want check if $a,$b and $c are all the same, you should have the condition like that: if($a==$b && $a==$c) { //do somthing; } else { //do something; } Moreover, in (condition1 && condition2), if condition1 is FALSE, then condition2 will not be checked/executed, in the case, if want to executed condition2, use (condition1 & condition2) instead The case is similar in (condition1 || condition2), if you want to execute condition2 no matter condition1 is TRUE or not, use (condition1 | condition2) Hope can help you

« previous php.notes (#53301) next »