Home > Article > Backend Development > What is the difference between == and = in php
The difference between == and = in PHP:
== in php is the comparison operator , used to compare two Whether the values are equal, if the types are different, the types of the two values will be converted and then compared.
Example:
var_dump(0 == "a"); // 0 == 0 -> true var_dump("1" == "01"); // 1 == 1 -> true var_dump("10" == "1e1"); // 10 == 10 -> true var_dump(100 == "1e2"); // 100 == 100 -> true
"=" in php is the assignment operator, used to assign values to variables.
In PHP, the basic assignment operator is "=". It means that the left operand is set to the value of the right-hand expression. That is, the value of "$x = 5" is 5.
For more related tutorials, please pay attention to php Chinese website.
The above is the detailed content of What is the difference between == and = in php. For more information, please follow other related articles on the PHP Chinese website!