Tuesday, July 31, 2018

php - The 3 different equals



What is the difference between =, ==, and ===?




I think using one equal sign is to declare a variable while two equal signs are for a comparison condition and lastly three equal signs are for comparing values of declared variables.


Answer



You have = the assignment operator, == the 'equal' comparison operator and === the 'identical' comparison operator.



$a = $b     Assign      Sets $a to be equal to $b.
$a == $b Equal TRUE if $a is equal to $b.
$a === $b Identical TRUE if $a is equal to $b, and they are of the same type. (introduced in PHP 4)


For more info on the need for == and ===, and situations to use each, look at the docs.



No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...