PHP
  Home arrow PHP arrow Page 4 - Output Buffering With PHP
Dev Shed Forums 
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Sun Developer Network 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Moblin 
JMSL Numerical Library 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
PHP

Output Buffering With PHP
By: Harish Kamath, (c) Melonfire
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 56
    2002-04-30

    Table of Contents:
  • Output Buffering With PHP
  • The Matrix Awaits
  • Start Me Up
  • Melting Down
  • Today's Forecast
  • Making It Simpler
  • The Real World
  • Zip Zap Zoom
  • Endgame

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Output Buffering With PHP - Melting Down


    (Page 4 of 9 )

    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:

    <?php// run at script startfunction page_init(){ // start buffering the output ob_start();}// run at script endfunction page_exit(){ global $error; // if an error occurred // erase all output generated so far // and display an error message if ($error == 1) { ob_end_clean(); print_error_template(); } // no errors? // display output else { ob_end_flush(); }}// print error pagefunction print_error_template(){ echo "<html><head><basefont face=Arial></head><body>An erroroccurred. Total system meltdown now in progress.</body></html>"; }page_init();// script code goes hereecho "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;page_exit();?>
    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.

    More PHP Articles
    More By Harish Kamath, (c) Melonfire


     

       

    PHP ARTICLES

    - Validating Web Forms with the Code Igniter P...
    - Output Buffering
    - Paginating Database Records with the Code Ig...
    - HTTP Headers in Web Development
    - Project Management: Administration
    - Building a Database-Driven Application with ...
    - User Authentication for a Project Management...
    - Introduction to the CodeIgniter PHP Framework
    - Adding Users for a Project Management Applic...
    - Migrating Class Code for a MIME Email to PHP...
    - Login and Logout Authentication for a Projec...
    - Composing Messages in HTML for MIME Email wi...
    - Project Management: Authentication
    - A Better Way to Determine MIME Types for MIM...
    - Project Management Overview





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway