Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a difference between !== and != in PHP?

Is there a difference between !== and != in PHP?

like image 420
barfoon Avatar asked Jul 16 '09 17:07

barfoon


People also ask

What is the differences between $a != $B and $a !== $B?

$b - Check if the value of $a is not equal to $b. However, with $a !== $b, the value of $a is matched with $b, and also the 'Type' which must be same. == check for value and === checks for value of same types on both operands.

What does !== Mean in PHP?

PHP's === Operator enables you to compare or test variables for both equality and type. So !== is (not ===) Copy link CC BY-SA 2.5.

What is the difference between the != And !== operators in Javascript?

means that two variables are being checked for both their value and their value type ( 8!== 8 would return false while 8!== "8" returns true). != only checks the variable's value ( 8!=

What is the difference between != And?

!= operatorThe inequality operator (!=) is the logical opposite of the equality operator. It means “Not Equal” and returns true where equality would return false and vice versa. Like the equality operator, the inequality operator will convert data types of values while comparing. For example 1 !=


1 Answers

The != operator compares value, while the !== operator compares type as well.

That means this:

var_dump(5!="5"); // bool(false)
var_dump(5!=="5"); // bool(true), because "5" and 5 are of different types
like image 144
Salty Avatar answered Sep 22 '22 13:09

Salty