ob_start()

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
ol4pr0
Forum Regular
Posts: 926
Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador

ob_start()

Post by ol4pr0 »

I am having troubles with ob_start

using the following i dont have any troubles using firefox or IE on win2k

Code: Select all

ob_start("gzhandler"); // or ob_start("ob_gzhandler");
// bunch of code
ob_end_flush();
ob_end_clean() however does result in a page not loading ( firefox and IE )

However the ob_start("gzhandler") and or ob_gzhandler as in the code above doesnt seem to work with IE and XP ( firefox loads up fine ).
XP does except ( ob_start(); and ob_end_flush(); )

Wondering the following.
a: is it me, something wrong with that ?
b: did somebody experience the same problem?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

I don't remember if it's done automatically or not, but the headers need to be changed to tell the browser to expect gzip compressed data:

Code: Select all

Date: Sat, 08 Jan 2005 04:50:20 GMT
Server: Microsoft-IIS/5.0
X-Powered-By: PHP/4.3.10
Content-Encoding: gzip
Cache-Control: private, pre-check=0, post-check=0, max-age=0
Expires: Sat, 08 Jan 2005 04:50:20 GMT
Last-Modified: Sat, 08 Jan 2005 04:50:20 GMT
Keep-Alive: timeout=25, max=100
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: text/html
^ sent by devnetwork's server.
kondro
Forum Newbie
Posts: 3
Joined: Sat Jan 08, 2005 3:20 am

Post by kondro »

That is the correct behaviour for ob_end_clean().

ob_end_start() starts the buffering of the output of the page to memory.

ob_end_clean() will delete anything in the buffer and stop buffering.

ob_end_flush() will output anything in the buffer and stop buffering.

the ob_* functions can be nested.
Shendemiar
Forum Contributor
Posts: 404
Joined: Thu Jan 08, 2004 8:28 am

Post by Shendemiar »

If you're just wanting to compress your pages, use .htaccess file.

add the following to you .htaccess

Code: Select all

php_flag zlib.output_compression on 
php_value zlib.output_compression_level 1
User avatar
teksys
Forum Commoner
Posts: 34
Joined: Tue May 14, 2002 6:58 pm
Location: Denmark

Post by teksys »

Shendemiar wrote:If you're just wanting to compress your pages, use .htaccess file.

add the following to you .htaccess

Code: Select all

php_flag zlib.output_compression on 
php_value zlib.output_compression_level 1
Gah...Unknown function. Damn host :(

-teksys
Post Reply