title: Is there a maximum amount of iterations PHP can loop?
body: <p>Given the right configuration, a very simple process and enough memory, does PHP have a ceiling on number of iterations in loops, or would it just continue to execute until you either exhausted the memory, hit the max execution time, or faulted in some other way?</p>
  
  <p>If so, is it different for the various types of loops? while, do...while, for, foreach?</p>
  
  <p><strong>For instance:</strong></p>
  
  <pre><code>&lt;?php 
  for ($i=0; $i&lt;999999999999999999; $i++) {
    echo "$i&lt;br/&gt;";
  };
  </code></pre>
  
  <p>I realize this is a little absurd, but it's mostly a curiosity of mine about PHP limitations.  I couldn't find anything in the docs or this specific question discussed here on SO.</p>
  
  <p>I did run this script in a local development environment running PHP 7.1 built in server on a 3.1GHz Intel Core i7 MacBook Pro with 16GB RAM, with a <code>max_execution_time</code> of zero.  After about 720,000 the browser itself would reach it's own limitations and freeze up.  I did run this same test via the CLI and while it took a really long time, it did execute and ran but I eventually manually stopped it.</p>