title: simplexml_load_string errors on big files occur on one system but not another
body: <p>I'm dealing with a third party PHP library that I can't edit, and it's been working fine for almost a year. It uses <code>simplexml_load_string</code> on the response from a remote server. Lately it's been choking on large responses. This is a data feed for real estate listings, and the format looks something like this:</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;RETS ReplyCode="0" ReplyText="Operation Successful Reference ID: 9bac803e-b507-49b7-ac7c-d8e8e3f3aa89"&gt;
  &lt;COUNT Records="9506" /&gt;
  &lt;DELIMITER value="09" /&gt;
  &lt;COLUMNS&gt;   sysid   1   2   3   4   5   6   &lt;/COLUMNS&gt;
  &lt;DATA&gt;  252370080   Residential 0.160   No  ADDR0   06051&lt;/DATA&gt;
  &lt;DATA&gt;  252370081   Residential 0.440   Yes ADDR0   06043&lt;/DATA&gt;
  &lt;DATA&gt;  252370082   Residential 1.010   No  ADDR0   06023&lt;/DATA&gt;
  &lt;DATA&gt;More tab delimited text&lt;/DATA&gt;
  &lt;!-- snip 9000+ lines --&gt;
  &lt;/RETS&gt;
  </code></pre>
  
  <p>I downloaded a sample file of a response (about 22MB), here's where I ended up with my debugging and sanity. Both servers are running PHP Version 5.3.8, but note the different results. I'm as certain as I can be that both files are the same (I suppose the different filesize, strlen, and last 50 chars can be explained by Windows newlines having an extra carriage return character). Test script:</p>
  
  <pre><code>error_reporting(-1);
  ini_set('display_errors', 1);
  $file = 'error-example.xml';
  $xml = file_get_contents($file);
  
  echo 'filesize:              ';
  var_dump(filesize($file));
  
  echo 'strlen:                ';
  var_dump(strlen($xml));
  
  echo 'simplexml object?      ';
  var_dump(is_object(simplexml_load_string($xml)));
  
  echo 'Last 50 characters:    ';
  var_dump(substr($xml, -50));
  </code></pre>
  
  <p>Output locally on Windows:</p>
  
  <pre><code>filesize:              int(21893604)
  strlen:                int(21893604)
  simplexml object?      bool(true)
  Last 50 characters:    string(50) "RD DR    CT  Watertown   203-555-5555            &lt;/DATA&gt;
  &lt;/RETS&gt;"
  </code></pre>
  
  <p>Output on remote UNIX server:</p>
  
  <pre><code>filesize:              int(21884093)
  strlen:                int(21884093)
  simplexml object?      
  Warning: simplexml_load_string(): Entity: line 9511: parser error : internal error in /path/to/test.php on line 19
  
  Warning: simplexml_load_string(): AULTED CEILING IN FOYER, BRICK FP IN FR, NEW FLOORING IN LR DR FR FOYER KITCHEN  in /path/to/test.php on line 19
  
  Warning: simplexml_load_string():                                                                                ^ in /path/to/test.php on line 19
  
  Warning: simplexml_load_string(): Entity: line 9511: parser error : Extra content at the end of the document in /path/to/test.php on line 19
  
  Warning: simplexml_load_string(): AULTED CEILING IN FOYER, BRICK FP IN FR, NEW FLOORING IN LR DR FR FOYER KITCHEN  in /path/to/test.php on line 19
  
  Warning: simplexml_load_string():                                                                                ^ in /path/to/test.php on line 19
  bool(false)
  Last 50 characters:    string(50) "ORD DR   CT  Watertown   203-555-5555            &lt;/DATA&gt;
  &lt;/RETS&gt;"
  </code></pre>
  
  <p>Some replies to comments and additional info:</p>
  
  <ul>
  <li><p>The XML itself appears to be valid as far as I can tell (and it <em>does</em> work on my system).</p></li>
  <li><p><code>magic_quotes_runtime</code> is definitely off.</p></li>
  <li><p>The working server has libxml Version 2.7.7 while the other has 2.7.6. Could that really make the difference? I could not find a libxml change log but it seems unlikely.</p></li>
  <li><p>This seems to only happen when the response/file is over a certain size, and the error always occurs at the next-to-last line.</p></li>
  <li><p>I am not running into memory issues, the test script runs instantly.</p></li>
  </ul>
  
  <p>There are differences in the PHP configurations which I can post if I knew which ones were relevant. Any idea what the problem could be, or know of anything else I might want to check?</p>