note 115848 added to function.ob-get-contents

From: Date: Fri, 03 Oct 2014 08:38:39 +0000
Subject: note 115848 added to function.ob-get-contents
Groups: php.notes 
Request: Send a blank email to php-notes+get-200576@lists.php.net to get a copy of this message
Note that, unlike PHP variables which make efficient use of memory, getting the contents of the output buffer results in a new copy of the buffer being made. This can end up massively increasing the memory requirements of your script if your output is large. Example code: <?php print(memory_get_usage() . "<br>"); ob_start(); for ($i = 0; $i < 5000000; $i++) print(" "); print(memory_get_usage() . "<br>"); $foo = ob_get_contents(); print(memory_get_usage() . "<br>"); ob_end_flush(); ?> Output: 351664 5359152 10359256 ---- Server IP: 72.52.91.14 Probable Submitter: 212.69.47.82 ---- Manual Page -- http://php.net/manual/en/function.ob-get-contents.php Edit -- https://master.php.net/note/edit/115848 Del: integrated -- https://master.php.net/note/delete/115848/integrated Del: useless -- https://master.php.net/note/delete/115848/useless Del: bad code -- https://master.php.net/note/delete/115848/bad+code Del: spam -- https://master.php.net/note/delete/115848/spam Del: non-english -- https://master.php.net/note/delete/115848/non-english Del: in docs -- https://master.php.net/note/delete/115848/in+docs Del: other reasons-- https://master.php.net/note/delete/115848 Reject -- https://master.php.net/note/reject/115848 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#200576) next »