note 48392 added to function.ob-get-contents
| From: | websurfer--nospam-- at digitalplatinum dot net | Date: | Wed, 22 Dec 2004 02:34:03 +0000 |
| Subject: | note 48392 added to function.ob-get-contents | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-82148@lists.php.net to get a copy of this message | ||
<?php
// Here is a simple example of capturing output to a string.
// This particular example is used as part of a
// content-management "publish" feature, implemented to
// generate static pages from dynamic pages, to reduce
// load on server/database yet still allow for a back-end
// database where owner can update content, etc.
// There are other ways of accomplishing this of course,
// but this has its advantages.
ob_start(); //start output buffering
include('dynamic_page.php'); //include the slow-loading dynamic page
$static_contents = ob_get_contents(); //capture output buffer to string
ob_end_clean(); //wipe output buffer and stop buffering
//output the fast-loading static page (PHP 5)
file_put_contents('static_page.php', $static_contents);
?>
----
Manual Page -- http://www.php.net/manual/en/function.ob-get-contents.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+48392
Delete -- http://master.php.net/manage/user-notes.php?action=delete+48392&report=yes
Reason: bad code -- http://master.php.net/manage/user-notes.php?action=delete+48392&report=yes&reason=bad+code
Reason: spam -- http://master.php.net/manage/user-notes.php?action=delete+48392&report=yes&reason=spam
Reason: useless example -- http://master.php.net/manage/user-notes.php?action=delete+48392&report=yes&reason=useless+example
Reason: contains commercial links -- http://master.php.net/manage/user-notes.php?action=delete+48392&report=yes&reason=contains+commercial+links
Reason: useless note -- http://master.php.net/manage/user-notes.php?action=delete+48392&report=yes&reason=useless+note
Reject -- http://master.php.net/manage/user-notes.php?action=reject+48392&report=yes
Search -- http://master.php.net/manage/user-notes.php