". The "!=" and "<>" operators are completely equivalent and have no difference. They are used to compare whether the values ​​​​of two objects are equal; while the "!==" operator means that they are absolutely not equal. In addition to comparing values, they will also compare type."/> ". The "!=" and "<>" operators are completely equivalent and have no difference. They are used to compare whether the values ​​​​of two objects are equal; while the "!==" operator means that they are absolutely not equal. In addition to comparing values, they will also compare type.">

Home >Backend Development >PHP Problem >What is the inequality operator in php and what

What is the inequality operator in php and what

青灯夜游
青灯夜游Original
2021-06-02 17:34:063470browse

The inequality operators in php are "!=", "!==" and "a8093152e673feb7aba1828c43532094". The "!=" and "a8093152e673feb7aba1828c43532094" operators are completely equivalent, without any difference, and are used to compare whether the values ​​​​of two objects are equal; while the "!==" operator indicates absolute inequality. In addition to comparing values, it also Will compare types.

What is the inequality operator in php and what

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

php inequality operator

Operator Name Description Instance
x != y is not equal to If x is not equal to y, return true 5!=8 Return true
x a8093152e673feb7aba1828c43532094 y is not equal to If x is not equal to y, return true 5a8093152e673feb7aba1828c435320948 Return true
x !== y Absolutely not equal If x is not equal to y, or they are not the same type, return true 5!= ="5" returns true

Instructions: In

php, a8093152e673feb7aba1828c43532094 and != These two are completely equivalent, without any difference. They are used to compare whether the values ​​​​of two objects are equal.

is not equal to !== In addition to comparing values, types will also be compared.

For example: 1 != '1' will return false, because the values ​​of number 1 and string 1 are equal,

1 !== '1' will return true because the two types are not equal

Example:

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

var_dump($x == $y); // returns true because values are equal
echo "<br>";
var_dump($x === $y); // returns false because types are not equal
echo "<br>";
var_dump($x != $y); // returns false because values are equal
echo "<br>";
var_dump($x !== $y); // returns true because types are not equal
echo "<br>";

$a=50;
$b=90;

var_dump($a > $b);
echo "<br>";
var_dump($a <  $b);
?>

Output:

bool(true)
bool(false)
bool(false)
bool(true)
bool(false)
bool(true)

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of What is the inequality operator in php and what. 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