What happens when the same numbers in PHP are not equal?

藏色散人
Release: 2023-03-08 19:08:01
Original
2678 people have browsed it

When PHP determines that the same numbers are not equal, it means that although they have the same value, their types are different. Therefore, when using the comparison operator equals symbol "===" in PHP to determine that two are the same When the number is , return false, indicating that the types are different.

What happens when the same numbers in PHP are not equal?

The operating environment of this article: windows7 system, PHP7.1 version, DELL G3 computer

When the same numbers in PHP are judged to be unequal, It means that although their values ​​are the same, their types are different. Therefore, when the comparison operator equals symbol "===" is used to judge two identical numbers and returns false, it means that the types are different.

==, equal to, $x == $y, returns true if $x is equal to $y.

===, congruent (identical), $x === $y, returns true if $x is equal to $y and they are of the same type.

Example:

<?php
$x = 17;  
$y = "17";

var_dump($x === $y); // 返回 false,因为类型不同
?>
Copy after login

Output result:

bool(false)
Copy after login

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of What happens when the same numbers in PHP are not equal?. 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!