title: PHP type juggling and decrement operator
body: <p>I am playing with the <code>for-loop</code> and <code>CLI</code> in PHP. I am having issue with decrement operator(--). Below is my code,</p>
  
  <pre><code>&lt;?php
  
      $handle = fopen("php://stdin","r");
      $str = fgets($handle);
      for($i=$str; $i&gt;0; $i--){   
          var_dump($i);
      }
  </code></pre>
  
  <p>It goes in to infinite loop for any number > 0. below is the output,</p>
  
  <pre><code>john@doe:/var/www/html/rank$ php 1.php
  3
  string(2) "3
  "
  string(2) "3
  "
  string(2) "3
  "
  string(2) "3
  "
  string(2) "3
  "
  string(2) "3
  "
  </code></pre>
  
  <p>but if I explicitly type cast cli argument to <code>int</code>, it works,</p>
  
  <pre><code>&lt;?php
  
      $handle = fopen("php://stdin","r");
      $str = (int)fgets($handle);
      for($i=$str; $i&gt;0; $i--){   
          var_dump($i);
      }
  </code></pre>
  
  <p>Output</p>
  
  <pre><code>john@doe:/var/www/html/rank$ php 1.php
  3
  int(3)
  int(2)
  int(1)
  john@doe:/var/www/html/rank$
  </code></pre>
  
  <p>Am I doing something wrong or type juggling does not work with decrement operator(intentionally)? as it seems working okay with increment operator(++) as below</p>
  
  <pre><code>&lt;?php
  
      $handle = fopen("php://stdin","r");
      $str = fgets($handle);
      for($i="1"; $i&lt;=$str; $i++){    
          var_dump($i);
      }
  </code></pre>
  
  <p>Output</p>
  
  <pre><code>john@doe:/var/www/html/rank$ php 1.php
  3
  string(1) "1"
  int(2)
  int(3)
  john@doe:/var/www/html/rank$
  </code></pre>