News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

PHPit.net:
Having fun with PHP's output buffer
April 17, 2006 @ 07:13:24

One of the more powerful and handy features that PHP offers is output buffering. It allows you more control over when the client's browser gets the information instead of just spewing information at random. It is a little tricky to get the hang of, so PHPit.net has put together this new tutorial on how to get started.

I'm sure most of us have come across the dreaded "Cannot modify header information - headers already sent", and this is usually caused when your script tries to send a header or set a cookie, when it's already sent output. The easiest fix is to make sure no output has been sent, but it's also possible to enable something called output buffering which also solves the problem.

In this article I'll first show you how output buffering works, and take you through most of its basic functions. After that we'll have a look at what's possible with output buffering, and show you some neat tricks.

The groundwork is laid first, giving a simple "Hello world" example to show how the code flows. They show how the buffering system works and how to use a callback function to modify the contents of the buffer before outputting (including a full replace function to text within the buffer from an array). They follow that with a look at creating your own HTML tags and using the gzip compression functionality to speed up your pages.

0 comments voice your opinion now!
output buffering example tutorial simple callback replace gzip output buffering example tutorial simple callback replace gzip


blog comments powered by Disqus

Similar Posts

Zend Developer Zone: AJAX Chat Tutorial Part 7 : Usability Improvements

HowToForge.com: LAMP Installation On Ubuntu 6.06 For Linux Noobs

Kevin Schroeder's Blog: New Zend Server Job Queue Library

php|architect: Introduction to Solar

HowToForge: How To Install a Complete LEMP on Ubuntu/Debian


Community Events





Don't see your event here?
Let us know!


podcast symfony2 language series testing release api laravel refactor unittest developer threedevsandamaybe interview code framework opinion list install community introduction

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework