Logo         Community
The Company
Your Account
Contact Us
Output Buffering With PHP
Use powerful filters to control the output of your PHP scripts.

| Melting Down |

Of course, there aren't just two functions available to you - the output control API has a few other cards up its sleeve as well. Consider the following example:


// run at script start
function page_init()
// start buffering the output

// run at script end
function page_exit()
global $error;

// if an error occurred
// erase all output generated so far
// and display an error message
if ($error == 1)
// no errors?
// display output

// print error page
function print_error_template()
echo "<html><head><basefont face=Arial></head><body>An error occurred. Total system meltdown now in progress.</body></html>";


// script code goes here
echo "This script is humming like a well-oiled machine";

// if an error occurs
// set the global $error variable to 1
// uncomment the next line to see what happens if no error occurs
$error = 1;



In this case, depending on whether or not a particular error condition is met, PHP will either display the contents of the buffer, or wipe it clean via the ob_end_clean() function.

How to do Everything with PHP & MySQL
How to do Everything with PHP & MySQL, the best-selling book by Melonfire, explains how to take full advantage of PHP's built-in support for MySQL and link the results of database queries to Web pages. You'll get full details on PHP programming and MySQL database development, and then you'll learn to use these two cutting-edge technologies together. Easy-to-follow sample applications include a PHP online shopping cart, a MySQL order tracking system, and a PHP/MySQL news publishing system.

Read more, or grab your copy now!

previous page more like this  print this article  next page
In trog...
Logging With PHP
Building A Quick-And-Dirty PHP/MySQL Publishing System
Date/Time Processing With PHP
Creating Web Calendars With The PEAR Calendar Class
Caching Web Sites With PEAR Cache
In the hitg report...
Crime Scenes
Animal Attraction
Lord Of The Strings
In boombox...
Patience - George Michael
Think Tank - Blur
My Private Nation - Train
In colophon...
Hostage - Robert Crais
The Dead Heart - Douglas Kennedy
Right As Rain - George Pelecanos
In cut!...
American Chai
The Core
Find out how you can use this article on your own Web site!

Copyright © 1998-2018 Melonfire. All rights reserved
Terms and Conditions | Feedback