![]() |
In PHP, the ‘=’ operator is used for assignment, while the ‘==’ operator is used for loose equality comparison, meaning it checks if two values are equal without considering their data types. On the other hand, the ‘===’ operator is used for strict equality comparison, meaning it checks if two values are equal and of the same data type. = OperatorThe equals to ‘=’ sign operator is used as an assignment operator. It assigns the value that is on its right side to the variable that is on its left side. Syntax:$variable = value Example: Implementation to showcase the use of ‘=’ operator.
Output 15.99 You are on portal of GeeksforGeeks 1 == OperatorThe ‘==’ is not used for assignment purpose. It is only used to compare the values of two given operands, not their data types. This operator is used to check if the given values are equal or not. If both the values are equal, it returns true, otherwise it returns false. In below example, the string “34” is automatically converted to the integer 34 for the comparison, and since both values are numerically equal, the condition is true and “Equal” is echoed. Syntax:operand1 == operand2 Example: Implementation to showcase the use of ‘==’ operator.
Output Equal Equal === OperatorThe ‘===’ won’t do assignment either. It is used to compare both values and data types of two given operands. It is a more strict version of ‘==’ operator. This operator is used to check if the given values and their data types are equal or not. If both the values are equal, it returns true, otherwise it returns false. Syntax:operand1 === operand2 Example: Implementation to showcase the use of ‘===’ operator.
Output Equal Not Equal Difference between the (=), (==), and (===) operators
|
Reffered: https://www.geeksforgeeks.org
PHP |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 14 |