note 6706 modified in Control Structures by zak

From: Date: Thu, 14 Sep 2000 08:25:55 +0000
Subject: note 6706 modified in Control Structures by zak
Groups: php.notes 
Request: Send a blank email to php-notes+get-4900@lists.php.net to get a copy of this message
New users often find testing multiple conditions within an IF statement or a looping construct (like WHILE, FOR, etc...) difficult. One way to make this task easier is to make sure to bracket each statement that you are testing. For example: # Simple tests need no brackets if ($x || $y) # This test does not require brackets # but they will improve readability if ($x || $y && $z) # See the difference? if (($x || $y) && $z) # If this code is not bracketed # you may not get the expected results if ( $a || $x xor $y || $z) # Bracket let PHP know exactly what you mean if ( ($a || $x) xor ($y || $z)) if ( $a || ($x xor $y) || $z) Good Luck! http://www.php.net/manual/control-structures.php

« previous php.notes (#4900) next »