Basically, I always use words ‘and’ & ‘or’ so, my scripts look like:
if ($value == '1' or $value == '2' or $value == '3') {
//do stuff
}
if ($value == '1' and $user_logged == 'Admin') {
//do stuff
}
- It’s possible get rid of of
$valuerepeating? - Any benefit in using
andandorinstead of||and&&?
There is no way to shortcut expressions like
But you can check the values in another way:
The difference between
orand || is operator precedence. Use || and &&, notorandand.