AR
"and" is not the same like && , also, "or" is not same like ||
&& is higher priority than "and" , also, || is higher priority than "or".
For example:
$a && $b || $c;
is not the same like:
$a and $b || $c;
the first thing is:
(a and b) or c
the second:
a and (b or c)
Because || has got a higher priority than and, but less than && .
Using always [ && and || ] or [ AND and OR ] would be okay, but than you should at least respect the following:
$a = $b && $c;
$a = $b and $c;
the first code will set $a to the result of the comparison $b with $c, both have to be true, while the second code line will set $a like $b and THAN - after that - compare the success of this with the value of $c .
<!DOCTYPE html PUBLIC "-//***WAPFORUM**.**RS***
AR
CreativityKills wrote:
i dnt undastand wth u talkn about. I use and and or, easier to read.
Look at this example from my site script:
if (!empty($a) and check_it($a) || strlen($a) != 32) { exit(errors()); }
if u write it like this:
if (!empty($a) && check_it($a) || strlen($a) != 32) { exit(errors()); }
index page will not open, this is gonna end up with exit; always because of priority. Its not the same.
<!DOCTYPE html PUBLIC "-//***WAPFORUM**.**RS***
AR
Me too until i came across this particular problem, when i researched a bit and used only once "and" in the script insted &&.
<!DOCTYPE html PUBLIC "-//***WAPFORUM**.**RS***
AR
<!DOCTYPE html PUBLIC "-//***WAPFORUM**.**RS***