tags:

views:

70

answers:

2

Hi

is that possible to do that?

<?php if($limit != "0" && $num_down < $limit || $limit == "0") {

//stuff

}
?>

i need to check if limit equals to 0 or if it is not, if $num_down is under limit.

Thank you

+6  A: 

Don't make it any more complicated than necessary:

if ($limit == 0 || $num_down < $limit) {
    ...
}

This works because the logical or (||) evaluates to true if either or both of its arguments evaluate to true.

Stephan202
+2  A: 
if( ($limit != 0 && $num_down < $limit) || $limit == 0 )
{
  whateves();
}

You can do it this way if you want to evaluate the first condition before the second. You can also use another if branch.

Check out the manual page for operator precedence

iddqd
this one seems ok for me thank you all
Ahmet vardar