Home >Backend Development >PHP Problem >What is the difference between == and = in php

What is the difference between == and = in php

尚
Original
2020-04-25 15:44:064376browse

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn