Posts Tagged “php examples”

I 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:

  1. // start buffering the output
  2. <?php
  3. // echo a possible mysql_error if it exists
  4. // get the buffered output and clean/stop the buffering
  5. $buffered_output = ob_get_clean();
  6. // save the output to a logfile - append if file exists
  7. file_put_contents("mysql.log.txt",$buffered_output,FILE_APPEND);
  8. ?>

Comments No Comments »