!==和==!之间的区别 PHP 运算符

!== 比较运算符

!==运算符使用类型检查来检查两个对象的不相等性。它不会转换数据类型并进行类型检查,例如1!=='1'的结果为true。

==! 比较运算符

'==!' 运算符是两个运算符的组合,可以写为==(!operands)。

示例

以下示例显示了'!=='与'==!'的用法 操作员。

<!DOCTYPE html>
<html>
<head>
   <title>PHP Example</title>
</head>
<body>
   <?php
      $x = true;
      $y = false;
      echo '$x !== operator $y = ';

      // $x 不等于 $y
      // 返回 true
      var_dump($x !== $y);
      print("<br/>");
      echo '$x ==! operator $y = ';
      // 返回 true
      var_dump($x ==! $y);
   ?>
</body>
</html>

输出结果

$x !== operator $y = bool(true)
$x ==! operator $y = bool(true)