Nov
09
2008
How To Use The PHP Output Buffer
Posted by: admin in PHP, tags: ob_start, PHP, php examplesI typically use the PHP output buffer to either change the output going to a page, or retrieve the output and direct it to a file.
For example, consider the following:
-
// start buffering the output
-
<?php
-
// echo a possible mysql_error if it exists
-
// get the buffered output and clean/stop the buffering
-
// save the output to a logfile - append if file exists
-
file_put_contents("mysql.log.txt",$buffered_output,FILE_APPEND);
-
?>













































































Entries (RSS)