Comparison operators perform test on their operands. They return the boolean value true if the
test is successful and return false otherwise . This type of expression is useful in control structures, such as if and while statements.You will meet this in Tutorial.
Ti test whether the value contained in $x is smaller than 5, for example ,you would use the less than operator:
$x<5;
If $x contained 2, this expression would be equivalent to the value true.If $x contained 8 the expression would resolve to false.
If x =3;
Operator Name Returns true if example result
= = Equivalence Left is equivalent to right $x= = 5 false
!= Non -equivalence Left is not equivalent to right $x !=6 true
= = = Identical Left is equivalent to right
and they are the same type. $x = = = 5 false
> Greater than Left is greater than right $x >5 true
>= Greater than Left is greater than $x >=3 true or equal to right
< less than Left is less than right $x<2 false
<= less than or equal to Left is less than $x <=3 true
or equal to right
These operators are most commonly used with integers or doubles,although the equivalence operator is also used to compare strings.
Post a Comment