Note that there are some explanatory texts on larger screens.

plurals
  1. POis_null($x) vs $x === null in PHP
    primarykey
    data
    text
    <blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://stackoverflow.com/questions/4662588/whats-the-difference-between-is-nullvar-and-var-null">What&#39;s the difference between is_null($var) and ($var === null)?</a> </p> </blockquote> <p>PHP has two (that I know of, and three if you count <code>isset()</code>) methods to determine if a value is null: <code>is_null()</code> and <code>=== null</code>. I have heard, but not confirmed, that <code>=== null</code> is faster, but in a code review someone strongly suggested that I use <code>is_null()</code> instead as it is specifically designed for the null-evaluation purpose. He also started talking about math or something.</p> <p>Anyway, the fact that <code>is_null()</code> is apparently slower also leads me to believe that it's doing more than <code>=== null</code> does and is probably preferred. Is there any reason to use one or the other? Is one always preferred? What about <code>isset()</code>?</p> <p>As an addendum to possibly not get this question closed, what about <code>isset()</code> vs. <code>is_null()</code>? It seems that all <code>isset()</code> will do is suppress the notice, so unless you actually <em>want</em> a notice for an undefined variable, any reason to use <code>is_null()</code> instead? How about if you know the variable is initialized at the time?</p> <p>Finally, is there any mathematical reason to prefer <code>is_null()</code> over <code>=== null</code>? Something about null not being comparable?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload