title: Comparing BOOLEAN TRUE to INTEGER value in PHP
body: <p>I have the following PHP (the server is running version 5.3.x) in a script which is giving me a result that I am having trouble understanding. The general idea of this code is that I have a "normal mode", and two maintenance modes. In the first maintenance mode, data is only evaluated and can be viewed by an admin but is not stored to the database. If I set <code>$maintenance_mode_enabled = 2;</code>, then the same "preview" output should be displayed but only SOME specific updates to the database should be processed. The reason I added the <code>==2</code> comparison is because I found the need for a third option after I had setup the true/false for the basic default maintenance mode. At any rate, I noticed 18 records on my last <code>maintenance_mode_enabled = true;</code> run that were partially updated during the process, just as though I had set <code>maintenance_mode_enabled = 2;</code>.</p>
  
  <pre><code>        $maintenance_mode_enabled = true;
  
          if ($maintenance_mode_enabled){
              echo "Case 0\n";
          }
  
          if (!$maintenance_mode_enabled){
              echo "Case 1\n";
          }
  
          if ($maintenance_mode_enabled == 2){
              echo "Case 2\n";
          }
  </code></pre>
  
  <p>The output I get is:</p>
  
  <pre><code>Case 0
  Case 2
  </code></pre>
  
  <p>From what I understood, true (being boolean) is definitely not equal to 3. I am familiar with some oddities when comparing false, NULL and 0, but this problem with integers and TRUE is entirely new to me.</p>
  
  <p>Any ideas as to why this isn't working? I realize that I can just as easily change <code>$maintenance_mode_enabled</code> to an integer instead of a bolean by default, and set it as either 0, 1 or 2 to get the desired results, but I really want to understand WHY this seems to defy logic.</p>