Double equal to (==) and triple equal to (===) both are use as compression operator in Php. But there is big difference between double equal to (==) compression operator and triple equal to (===) compression operator.
Double equal to (==) compression operator can only compare the value but triple equal to (===) compression operator compare the value as well as data type of the value. This will be completely clear while seeing the below example.
Example :-
Comparing two value using double equal to compression operator
Output of the above code
The above example clearly shows that the variable 'b' contain string value but the output shows both the values are same.
Now the same example is performed using the triple equal to compression operator
Output of the above code
While using the triple equal to compression operator the output shows both the values are not same as it compare the value as well as data type of the value.
No comments:
Post a Comment