I have 145064642 chars long HTML String which I am trying to print.
When I try echo/var_dump/die on it it cause page to return false(0), but if i try to print only half of the variable it is working fine.
EXAMPLES:
Don’t work:
echo $MY_HTML_STR;
die($MY_HTML_STR);
var_dump($MY_HTML_STR)
Each of the two line works:
die(var_dump(substr($MY_HTML_STR,strlen($MY_HTML_STR)/2)));
die(var_dump(substr($MY_HTML_STR,0,strlen($MY_HTML_STR)/2)));
But when trying to print the both together:
var_dump(substr($MY_HTML_STR,strlen($MY_HTML_STR)/2));
die(var_dump(substr($MY_HTML_STR,0,strlen($MY_HTML_STR)/2)));
it is crashing again.
One way of echoing did gave me an error:
echo <<<EOF
TEXTTEXT...
$MY_HTML_STR
BLABLAHTML...
EOF;
the error: Fatal error: Out of memory (allocated 324009984) (tried to allocate 145090561 bytes) in .....page.php on line 675
Line 675 is the EOF; line.
The script is running on my home computer using WAMPSERVER and memory_limit set as -1 (UNLIMITED).
Check if output buffering is on. Remember that if output buffering is enabled, everything you output will be held in memory until output is flushed (which also happens implicitly on script shutdown).
Try an ob_end_clean() before you print and see if that resolves your issue.
Also, try adding the code below before you print. You could be in nested output buffering (if, for example, you have it enabled in php.ini and you call ob_start at the beginning of your script)