note 37648 added to function.ob-start
| From: | ed dot oohay at rn2 dot php dot net | Date: | Fri, 21 Nov 2003 22:18:00 +0000 |
| Subject: | note 37648 added to function.ob-start | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-60773@lists.php.net to get a copy of this message | ||
Output Buffering even works in nested scopes or might be applied in recursive structures... thought
this might save someone a little time guessing and testing :)
<pre><?php
ob_start(); // start output buffer 1
echo "a"; // fill ob1
ob_start(); // start output buffer 2
echo "b"; // fill ob2
$s1 = ob_get_contents(); // read ob2 ("b")
ob_end_flush(); // flush ob2 to ob1
echo "c"; // continue filling ob1
$s2 = ob_get_contents(); // read ob1 ("a" . "b" . "c")
ob_end_flush(); // flush ob1 to browser
// echoes "b" followed by "abc", as supposed to:
echo "<HR>$s1<HR>$s2<HR>";
?></pre>
... at least works on Apache 1.3.28
Nandor =)
----
Manual Page -- http://www.php.net/manual/en/function.ob-start.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+37648
Delete -- http://master.php.net/manage/user-notes.php?action=delete+37648&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+37648&report=yes
Search -- http://master.php.net/manage/user-notes.php