In PHP, two equal signs "==" means "equal". It is a comparison operator used to compare whether the expressions or variables on both sides of the equal sign are equal. It only compares values, not types; Returns true if they are equal, false if not.
The operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer
In php, two equal signs "= "=" means "equality" and is a comparison operator used to compare whether the expressions or variables on both sides of the equal sign are equal.
Use two equal signs "==" for comparison. Only values are compared, not types.
There is also a triple equal sign "==" in PHP, which means "identity", that is, absolute equality (both values and types are equal); using three equal signs === for comparison, in addition to comparing values, also Compare types.
For example, "42" is a string and 42 is an integer. FALSE is a boolean value and "FALSE" is a string.
<?php if(42 == "42") { echo '1、值相等'; } echo PHP_EOL; // 换行符 if(42 === "42") { echo '2、类型相等'; } else { echo '3、类型不相等'; } ?>
Output:
1、值相等 3、类型不相等
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of What do the two equal signs mean in php?. For more information, please follow other related articles on the PHP Chinese website!