PHP 中 !== 和 ==! 運算子的區別
'!==' 比較運算子
'!==' 運算子檢查兩個物件的型別是否相等。它不轉換資料型別,而是執行型別檢查。例如,1 !== '1' 會返回 true。
'==!' 比較運算子
'==!' 運算子是兩個運算子的組合,可以寫成 == (!運算物件)。
示例
下面的示例展示了 '!=='' 和 '==!' 運算子的用法。
<!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>
輸出
$x !== operator $y = bool(true) $x ==! operator $y = bool(true)
廣告