PHP 5.2.12 - Interesting Switch Statement Bug With Integers and Strings
<pre><code>&lt;?php
$var = 0;
switch($var) {
   case "a":
      echo "I think var is a";
   break;
   case "b":
      echo "I think var is b";
   break;
   case "c":
      echo "I think var is c";
   break;
   default:
      echo "I know var is $var";
   break;
}
?&gt;
</code></pre>

<p>Maybe someone else will find this fascinating <em>and</em> have an answer. If you run this, it outputs <code>I think the var is a</code> when <em>clearly</em> it's <code>0</code>. Now, I'm most certain this has something to do with the fact that we're using strings in our <code>switch</code> statement but the variable we're checking is an integer. Does anyone know why PHP behaves this way? It's nothing too major, but it did give me a bit of a headache today.</p>

<p>Thanks folks!</p>
