As a PHP developer, I was wondering whether we can have something similar [to Streaming in Rails] in our favorite language? The answer is yes – we can easily have streaming in PHP applications with little effort, but in order to get this right we have to become familiar with some underlying concepts. In this article, we will see what streaming is, what output_buffering is and how to get our desired result under different webservers (Apache, Nginx) and PHP configurations (CGI, mod_php, FastCGI).

He starts off with a comparison of the two different methods, streaming and output buffering, and how they behave in the output of content. He then gets into some simple examples with PHP with various methods: a simple delay, chunking up output and finally using the actual output buffering handling PHP offers. He also includes an example of streaming content over an Ajax request with a simple test using the sleep function.

On PHPBuilder.com there's a new article with a few things - six things, to be exact - that you might not know about the PHP language as written up by Chris Roane.

Over the years I've come across some useful tricks in PHP that are not obvious, but are worth mentioning. This is not meant to be a comprehensive list of all the useful tricks that you can do with PHP.

DevShed has posted the second article in their series looking at benchmarking your PHP scripts. This time they look at the use of "timers" to check on script execution length.

Since you already know how to create timer functions and classes, in this tutorial, I'll create some concrete examples that show where these timing mechanisms can be applied in order to evaluate the performance of certain PHP applications.

They create a few classes that connect to a database and pull out rows (handing it off to a Result class). They use these classes in two examples - one with compression (output buffering) and one without using their Timer class to evaluate the differences.

Arnold Daniels has a quick little tutorial posted to his blog about using the output handler in PHP (one of what he considers a technique that's "missing out" from normal PHP use). His example involves buffering the common page parts - like a template.

A website usually has a part which is common across all pages, containing the HTML header, the menu and those kinds of things. This is often solved in one of four ways. [...] All of these methods work, however there is a better way to solve this. You guessed it, by using an output handler.

He links to an example he's created and includes the code for his OutputHandler class to make controlling the content easier.

Arnold Daniels has a quick little tutorial posted to his blog about using the output handler in PHP (one of what he considers a technique that's "missing out" from normal PHP use). His example involves buffering the common page parts - like a template.

A website usually has a part which is common across all pages, containing the HTML header, the menu and those kinds of things. This is often solved in one of four ways. [...] All of these methods work, however there is a better way to solve this. You guessed it, by using an output handler.

He links to an example he's created and includes the code for his OutputHandler class to make controlling the content easier.

PHP-GTKers working in English-related applications, don't have a problem with debugging messages output to a console when debugging, but applications on a more international front have issues with their output. But help has been found in this new post on the Riff Blog - a method for correctly encoding PHP-GTK applications.

PHP scripts are typically stored under UTF-8 encoding to limit i18n headaches, while the console in which their output will be displayed is normally configured to some regional encoding, like IBM850 in Windows/XP French.

So we need a workaround...

He splits the process out into a few steps, each with its own explanation and code:

Builtin tools

Buffering

Flushing

PHP-GTK is not PHP for the Web

Auto-flushing

All wrapped up with a final solution - using the iconv functionality in combination with some output buffering to correctly display the message.

PHP-GTKers working in English-related applications, don't have a problem with debugging messages output to a console when debugging, but applications on a more international front have issues with their output. But help has been found in this new post on the Riff Blog - a method for correctly encoding PHP-GTK applications.

PHP scripts are typically stored under UTF-8 encoding to limit i18n headaches, while the console in which their output will be displayed is normally configured to some regional encoding, like IBM850 in Windows/XP French.

So we need a workaround...

He splits the process out into a few steps, each with its own explanation and code:

Builtin tools

Buffering

Flushing

PHP-GTK is not PHP for the Web

Auto-flushing

All wrapped up with a final solution - using the iconv functionality in combination with some output buffering to correctly display the message.

If you're using the CakePHP framework and are having a problem with output buffering, this quick tip on the ThinkingPHP blog might work for you.

Output buffering is a useful way to accomblish things in php like gzipping all html output and such. A while ago I wrote about it on this blog (see "A miracle called gzip") as well.

The reason I write about it again is, that I have discovered a little issue with it in CakePHP.

He notes that if you just use the ob_start with the gzip handler, debug issues arise. The soultion he's come up with, though, isn't quite as simple, but gets the job done in about ten lines and is easy to drop in anywhere.