This tutorial is for Triple Equals.
Let me justify you difference between Double Equal Operator and Triple Equal Operator:-
Single Equal Operator:-It is used for assigning values.
Double Equal Operator:-It is used for equality between variables and values.
Triple Equal Operator:-It is used for equality between variables and values and there datatype too.
Code for comparison operators (Screenshot1):-
Screenshot1 |
Output (Screenshot2) :-
Screenshot2 |
In this example we had two variables where num1 is string datatype and num2 is integer datatype.Here,in “Double Equals” we can compare the values of variables num1 and num2,but what if we want to compare datatypes of variable along with the comparison of values.Let’s see an example:-
Code for Triple Equals Operators (Screenshot3):-
Code for Triple Equals Operators Screenshot3 |
Output (Screenshot4):-
Screenshot4 |
In this example during comparison of datatype of the variable i.e. string and integer, it evaluates false and echo out “Not equal”.
No comments:
Post a Comment
Thanks For Comment Will get you Soon..