All three methods are a check for null,
if($sth == NULL)
if($sth === NULL)
if(is_null($sth))
which way is the proper one?
They check three different things:
if ($sth == NULL)
This checks if $sth
is loosely equal to null
. This means that this would pass if $sth
was actually 0
.
if ($sth === NULL)
This checks if $sth
is exactly equal to null
.
if (is_null($sth))
This checks if the type of $sth
is the null type (the others test the value of $sth
).
The ===
and is_null
techniques will always give the same answer; ==
will sometimes give a different answer.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With