Page 1 of 1

HELP! Using AND or OR

Posted: Mon Jan 17, 2005 8:17 am
by Hagar
How would I use AND or OR
ie.

Code: Select all

if($x != $y or $y <= $z)&#123;
bla bla bla........

&#125;
or Must I Use

Code: Select all

if($x != $y || $y <= $z)&#123;
bla bla bla........
&#125;
like in C++

and the same with AND

Code: Select all

if($x != $y and $y <= $z)&#123;
bla bla bla........
&#125;
or Must I Use

Code: Select all

if($x != $y && $y <= $z)&#123;
bla bla bla........
&#125;

Posted: Mon Jan 17, 2005 8:25 am
by feyd
you can use either, depending on how you want the precendence to work.. check the documentation here to read about their differences..


notice how &&, ||, and ^ are processed before assignment operators. Judging by the logic you have used in your examples, the first ones are the ones (and/or) would perform as you expect it would. Whereas the ||/&& ones will likely not.