Skip to content
Advertisement

Is there a ‘greater and lesser than’ comparison operator?

Is there an operator that denotes a variable as both greater and lesser than? The following code block is not valid code.

if (0 < $variable < 5)
{
    etc
}

Advertisement

Answer

No. You’d want to use an “AND” operator, &&:

if ($variable > 0 && $variable < 5) {
   // bla.. bla.. bla..
}
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement