Equal Operator ==
The comparison operator called Equal Operator is the double equal sign “==”. This operator accepts two inputs to compare and returns true value if both of the values are same (It compares only value of variable, not data types) and return a false value if both of the values are not same.
This should always be kept in mind that the present equality operator == is different from the assignment operator =. The assignment operator changes and assigns the variable on the left to have a new value as the variable on right, while the equal operator == tests for equality and returns true or false as per the comparison results.
Identical Operator ===
The comparison operator called as the Identical operator is the triple equal sign “===”. This operator allows for a much stricter comparison between the given variables or values.
This operator returns true if both variable contains same information and same data types otherwise return false.
Data type or value are different
In the above example, value of $x and $y are equal but data types are different so else part will execute.
- Java | ==, equals(), compareTo(), equalsIgnoreCase() and compare()
- CopyOnWriteArrayList equals() method in Java with Examples
- String comparison using == vs strcmp() in PHP
- Comparison between static and instance method in PHP
- Double not (!!) operator in PHP
- PHP | Operators
- PHP | Bitwise Operators
- unordered_set operators in C++ STL
- HTML5 | Mathematical operators
- How to make an image center-aligned (vertically & horizontally) inside a bigger div using CSS?
- What does the CSS rule “clear: both” do?
- How to break line without using <br> tag in HTML / CSS ?
- HTML | Scientific Calculator
- HTML | DOM option index Property
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.