On Wed, September 20, 2006 7:13 pm, Christopher Watson wrote:
> I've been coding with PHP for maybe a year.  So I'm somewhat new to
> it.  But I've learned quickly, and created a fairly serious LAMP app
> that is capable of returning large query results.  During my
> investigation into various means for incrementally reducing the
> response sizes, I've discovered output buffering with a callback
> function.  So, as an experiment, I bracketed my includes of the
> Fusebox files in index.php with ob_start('sweeper') and
> ob_end_flush(), and placed the simple callback function at the top of
> the file that performs a preg_replace on the buffer to strip all
> excess space:
>
> function sweeper($buffer) {
>     return preg_replace("/\s\s+/", " ", $buffer);
> }

Here's where you MIGHT get bit in the butt:
  1. Anything in a PRE tag is gonna suck big-time
  2. Any kind of DATA from your db with multiple spaces will lose data

Now, you might maybe be able to fix these by religiously always doing
$output = str_replace(' ', '&nbsp', $output);
on the DATA from the DB, or any kind of PRE tags stuff you use.

Or maybe in YOUR application, neither of these matters.

Test it with JUST the output buffer and without the whitespace crunch
-- You may find that the ob is the big win, especially if you have a
zillion echo statements going on.

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to