What is the difference between == and = in php

Release: 2023-02-28 20:04:02
Original
4229 people have browsed it

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
Copy after login

"=" 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!

Related labels:
php
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!