At 22:13 13.03.2003, Liam Gibbs said: --------------------[snip]-------------------- >I know that in a case like this > >if((test1) && (test2) && (test3)) { > ... >} > >if test1 fails, dear PHP won't bother doing test2 and 3. Am I correct? Is >there a syntax that will make it carry on with test2 and 3 anyway, >regardless of how test1 came out? --------------------[snip]--------------------
The rule for AND chains is: - evaluate the expressions from left to right - stop AND DON'T RUN THE IF-BLOCK at the first expression evaluating to false The rule for OR chains is: - evaluate the expressions from left to right - stop AND RUN THE IF-BLOCK at the first expression evaluating to true This feature is inherent to all (well, most at least) languages - so be aware of side effects (or no side effects occurring) with such constructs. To allow _all_ expressions to be evaluated you need to run all 3 by themselves, later comparing the results: $x1 = test1(); $x2 = test2(); $x3 = test3(); if ($x1 && $x2 && $x3) ... -- >O Ernest E. Vogelsinger (\) ICQ #13394035 ^ http://www.vogelsinger.at/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php