Reputation: 395
I have a problem in writing interval condition inside IF ELSE: This is my condition :
if(1<x<=30)
{ statement }
else
{ statement }
Upvotes: 0
Views: 611
Reputation: 6539
In simple case, Ternary operator is best in practise.
$result = ($x > 1 && $x<=30) ? true : false;
Upvotes: 0
Reputation: 6110
You can use like this::
if(1<x && x<=30)
{ statement }
else
{ statement }
Upvotes: 0
Reputation: 16117
You can use like this:
if(1 < $x AND $x <= 30)
echo true;
else
echo false;
Upvotes: 0
Reputation: 3195
If you want to check interval/range then you can do it using following:
if($x > 1 && $x <= 30){
statement
}else{
statement
}
Upvotes: 3