Below you can see my code. It outputs the 'The number is hundred'. It works perfectly.
$var = 100;
switch($var){
case (100):
echo 'The number is hundred';
break;
default:
echo 'default';
break;
}
//Output:
The number is hundred
I just wanting to know this for the purpose of understanding if it's possible to do something like this:
case (greather then 100):
case (> 100):
And could you also explain why it's not possible or is possible?
It's possible, but it's not considered a good coding practise as switchs
should only do equality evaluations.
To do it use this syntax:
switch (TRUE) {
case ($var == 100): echo 'The number is one hundred';
case ($var > 100): echo 'The number is greater than one hundred';
echo 'default';
}