title: Detect null column value in PHP mysqli
body: <p>I have a php project that uses mysqli to query a database. Some of the columns in this database can be null. I have code that looks something like this:</p>
  
  <pre><code>$query = "...";
  $result = $DB-&gt;query($query);
  $row = $result-&gt;fetch_assoc();
  $column = $row['mycolumn'];
  </code></pre>
  
  <p>If <code>mycolumn</code> is null, the value of <code>$column</code> appears to be the string, <code>"NULL"</code> (NOT the null value, but actually the string containing the word "NULL"). So what happens if I have columns which actually have the string <code>"NULL"</code> in them? How can I differentiate?</p>
  
  <p>Thanks!
  Josh</p>
  
  <p>EDIT:
  Upon closer inspection, it appears that the string is actually a 5-characters string. The first 4 characters are <code>"NULL"</code>, but the last character is 0x0d, the carriage return. This makes it a lot easier to detect, although I'm still curious if there's a less hack-y way than just doing string comparison.</p>