Difference between !== and ==! operator in PHP


'!==' comparison operator

'!==' operator checks the unequality of two objects with a type check. It does not converts the datatype and makes a typed check.For example 1 !== '1' will results true.

'==!' comparison operator

'==!' operator is combination of two operators and can be written as == (!operands).

Example

Following example, shows usage of '!==' vs '==!' operators.

 Live Demo

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

      // $x not equals to $y
      // so true returned
      var_dump($x !== $y);
      print("<br/>");
      echo '$x ==! operator $y = ';
      // !$y is true which is same as $x
      // so true returned
      var_dump($x ==! $y);
   ?>
</body>
</html>

Output

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

Updated on: 13-Jan-2020

391 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements