Home >Backend Development >PHP Problem >What happens when the same numbers in PHP are not equal?

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

藏色散人
藏色散人Original
2021-03-17 11:09:142739browse

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,因为类型不同
?>

Output result:

bool(false)

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!

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