code to test simplexml_load_string capacity

121 views Asked by At

I am having trouble with PHP simplexml_load_string command failing on large strings. I would like to test how many characters can be parsed before the command fails. Is this code suitable for such a test? can someone suggest better?

<?php
$string = "";
$increment = 0;

if (ob_get_level() == 0) ob_start();


        for ($x = 1; $x <= 500; $x++)
{
        $string = "<?xml version='1.0'?><new-wrapper>";
        for ($y = 0; $y <= $increment; $y++) {
                $string = $string .  "<content>some content</content>";
                }
        $string = $string .  "</new-wrapper>";
        echo " String length is<b> " . strlen($string) ."</b>";

        // $xml = simplexml_load_string($string);
        $xml = simplexml_load_string($tring, 'SimpleXMLElement', LIBXML_NOCDATA | LIBXML_PARSEHUGE);

        $increment = $increment + 300;
        ob_flush();
        flush();
        usleep(100000);
}
echo "THE END";

To test in conjunction with php memory_limit vale in php.ini.

0

There are 0 answers