php if statement with one of two conditions if( a < b) or (b=0)

12,100
if( ($a < $b) || ($b==0) )
{
     //do something
}

or even better

if( ($a < $b) || (0==$b) )
{
     //do something
}

so you don't accidentally assign 0 to $b.

Share:
12,100
Michael
Author by

Michael

Updated on June 18, 2022

Comments

  • Michael
    Michael almost 2 years

    I have some huge blocks of code and I would like to avoid using elseif so the question is : Is it possible to construct an IF function with two possibilities in the same statement ? something like

      if( a < b) or (b=0)
    {
    statement
    }
    

  • Subdigger
    Subdigger over 12 years
    or even if( $a < $b || $b==0 )
  • Kaken Bok
    Kaken Bok over 12 years
    Who assigns 0 to b when writing b == 0?
  • Luchian Grigore
    Luchian Grigore over 12 years
    You can accidentally write b=0, like @ajreal did in his response about half an hour ago...