What's the difference between the following codes in php?
if ($resultado_barganha->tipo === "t") { }
E:
if ($resultado_barganha->tipo == "t") { }
From what I've noticed they do the same thing. However netbeans recommends === why?
What's the difference between the following codes in php?
if ($resultado_barganha->tipo === "t") { }
E:
if ($resultado_barganha->tipo == "t") { }
From what I've noticed they do the same thing. However netbeans recommends === why?
== checks to see if the conditions that were compared are the same, regardless of type, eg
if(true == true) // Verdadeiro
if(true == 1) // Verdadeiro
=== It checks whether the conditions are equal and also checks the type, ie both the information and the type must be the same, eg
if(true === true) // Verdadeiro
if(true === 1) //Falso
if(1 == 1) //Verdadeiro
Returns false because 1 is integer and true is not integer type but boolean
When using == it is only checked if the two values are equal.
But when you use === is checked if the two values are equal and if there is no information it will be set to "t", I have never used it with a string, I usually use it to do for example:
if ($ result_bargain-> type === false) {}
According to the document:
$a == $b Igual Verdadeiro (TRUE) se $a é igual a $b.
$a === $b Idêntico Verdadeiro (TRUE) se $a é igual a $b, e eles são do mesmo tipo.
There is no better explanation than this, at least I think.