What is the difference between == and == in one condition?

Asked

Viewed 1,111 times

4

What’s the difference between == and === in a condition, for example:

if($string === $string2) 

and

if($string == $string2) 
  • 1

    Jorge, I believe you already have an answer in another question that is not necessarily duplicated: http://answall.com/a/69576/8493

  • 1

    will be related? http://answall.com/questions/3186/qual-a-diferen%C3%A7a-entre-operadores-e-em-javascript

  • @Cesarmiguel this is in Javascript.

1 answer

6


The operator == only checks that left and right values are equal. The operator ===, checks if left and right values are equal, and also checks to see if they are of the same variable type.

$a == $b    Igual      TRUE se $a é igual a $b.
$a === $b   Idêntico   TRUE se $a é igual a $b, e eles são do mesmo tipo. (introduced in PHP 4) 

Reference:
That question on the Soen;
Comparison in the documentation

Browser other questions tagged

You are not signed in. Login or sign up in order to post.