Difference between two and three equal signs in comparisons
Question by Guest | Last update on 2021-05-04 | Created on 2012-08-11
I recently found a comparison with three equal signs in a script. Otherwise, I have always known only comparisons with two equals signs.
According to my tests, it does not matter whether you take two or three equal signs. So, what is this?
Related Topics
Which animal am I in the Chinese Horoscope?
Info | 0 Comments
PHP: Fill Array with Sequence of Numbers or Characters
Tutorial | 0 Comments
MySQL: Delete Data from Table - Difference between TRUNCATE, DELETE and DROP
Tutorial | 0 Comments
Local Gravity for different Places and Planets
Info | 0 Comments
MySQL: Line Breaks in MySQL
Tip | 0 Comments
Chinese Horoscope: Zodiac Signs and Elements
Info | 0 Comments
Car Purchase: How to detect a manipulated tachometer?
Info | 0 Comments
Important Note
Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.
Participate
Ask your own question or write your own article on askingbox.com. That’s how it’s done.
The operator == as well as the operator === are both comparision operators.
Here is an example:
// 3 variables with identical values $a = 10; $b = 10; $c = 10; // $a and $b of type integer, $c of type double settype($a, integer); settype($b, integer); settype($c, double); // comparison of the variables if ($a == $b) {} // true if ($a == $c) {} // true if ($a === $b) {} // true if ($a === $c) {} // falseWe define 3 variables with identical values and then cast the variables on the types Integer or Double. Then, we compare the variables in pairs.
When compared with the two equal signs, every time we get out true. In the three equal sign comparison, however, we get only true if the types are also the same.
Last update on 2021-05-04 | Created on 2012-08-12