+ 1

What is the difference between == and === operator.

in PHP ,c++ or Java language

4th Mar 2017, 5:31 AM
Mamta kumari
Mamta kumari - avatar
3 Respuestas
+ 13
== - unstrict comparison, so it TRIES to change type of values before comparison: 0 == false "" == false 5 == "5" === checks TYPE also, so you will not be able to compare different types of values: 0 === false // No 5 === "5" // Returns false
4th Mar 2017, 6:10 AM
WittyBit
WittyBit - avatar
+ 2
Depends on the language!
4th Mar 2017, 6:33 AM
1of3
1of3 - avatar
0
In PHP == is equal operator and returns TRUE if $a is equal to $b after type juggling and === is Identical operator and return TRUE if $a is equal to $b, and they are of the same data type. Example Usages: <?php $a=true ; $b=1; // Below condition returns true and prints a and b are equal if($a==$b){ echo "a and b are equal"; }else{ echo "a and b are not equal"; } //Below condition returns false and prints a and b are not equal because $a and $b are of different data types. if($a===$b){ echo "a and b are equal"; }else{ echo "a and b are not equal"; } ?> Source:https://www.onlineinterviewquestions.com/
25th Feb 2018, 7:38 PM
Vijay Kumar
Vijay Kumar - avatar