title: How to Catch a String Overflow Error in PHP, or how to prevent it?
body: <p>I have the following error:</p>
  
  <pre><code>Fatal error: String size overflow in /Users/jMac-NEW/Word_trial/PHPExcel_1.7.8-
  with_documentation-msoffice_format/Classes/PHPExcel/Shared/OLERead.php on line 233
  </code></pre>
  
  <p>The original code is PHPExcels's <em>OLERead.php</em>:</p>
  
  <pre><code>$block = $bl;
  $data = '';
  
  while ($block != -2)  {
      $pos = ($block + 1) * self::BIG_BLOCK_SIZE;
      $data .= substr($this-&gt;data, $pos, self::BIG_BLOCK_SIZE); // this is line 233
      $block = $this-&gt;bigBlockChain[$block];
  }
  return $data;
  </code></pre>
  
  <p>The API for this code reads: </p>
  
  <pre><code>/**
   * Read a standard stream (by joining sectors using information from SAT)
   *
   * @param int $bl Sector ID where the stream starts
   * @return string Data for standard stream
   */
  </code></pre>
  
  <p>How do I either catch this error or prevent it? Try catch doesn't work (bec fatal error?)
  I also refer to the answer in <a href="https://stackoverflow.com/questions/18545217/php-excel-memory-limit-of-2gb-exhausted-reading-a-286kb-file">PHP Excel Memory Limit of 2GB Exhausted reading a 286KB file</a>, which stated that what was "causing the memory overflow was [an .xls file] downloaded in ASCII mode instead of Binary". However, instead of downloading via FTP as per the situation in that post, I retrieved the files using RecursiveDirectoryIterator and RecursiveIteratorIterator. Apparently the file's size I am working with is 28956bytes, very similar situation to that post. But in my case how do I make the change of downloading to Binary VS ASCII?</p>
  
  <p>Please let me know if additional details required.</p>