implicit flushing

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

User avatar
tecktalkcm0391
DevNet Resident
Posts: 1030
Joined: Fri May 26, 2006 9:25 am
Location: Florida

implicit flushing

Post by tecktalkcm0391 »

I am confused on what exactly ob_implicit_flush does... any help?
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: implicit flushing

Post by Christopher »

As I recall, flushing is set Off by default. So when you echo it is put in the output buffer and the output buffer is sent when the script ends. If you turn implicit_flush On the every echo is sent to the browser immediately. The function ob_implicit_flush() allows you to set the flag to On or Off.
(#10850)
User avatar
tecktalkcm0391
DevNet Resident
Posts: 1030
Joined: Fri May 26, 2006 9:25 am
Location: Florida

Re: implicit flushing

Post by tecktalkcm0391 »

So pretty much that is a way to make the page start to download on the client-side while PHP is still processing what HTML to send?
User avatar
tecktalkcm0391
DevNet Resident
Posts: 1030
Joined: Fri May 26, 2006 9:25 am
Location: Florida

Re: implicit flushing

Post by tecktalkcm0391 »

I am having trouble getting the implicit flushing to be site wide via .htaccess file.. i have the following but it gives an internal error on the whole site:

Code: Select all

php_value implicit_flushing On
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: implicit flushing

Post by Chris Corbyn »

tecktalkcm0391 wrote:I am having trouble getting the implicit flushing to be site wide via .htaccess file.. i have the following but it gives an internal error on the whole site:

Code: Select all

php_value implicit_flushing On
Wrong directive isn't it?

Code: Select all

php_value implicit_flush On
There's no "ing".
User avatar
tecktalkcm0391
DevNet Resident
Posts: 1030
Joined: Fri May 26, 2006 9:25 am
Location: Florida

Re: implicit flushing

Post by tecktalkcm0391 »

i am still getting an internal error (500) with my .htaccess file looking like this:

Code: Select all

 
php_value implicit_flush On
 
RewriteEngine On
RewriteBase /
 
# remove the www
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
 
# remove index file access 
RewriteRule ^index\.(php|html|htm) http://SITE.com/ [R=301,L]
 
 
# remove .php; use THE_REQUEST to prevent infinite loops
RewriteCond %{THE_REQUEST} ^GET\ (.*)\.php\ HTTP
RewriteRule (.*)\.php$ $1 [R=301]
 
 
# remove index
RewriteRule (.*)/index$ $1/ [R=301]
 
# remove slash if not directory
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} /$
RewriteRule (.*)/ $1 [R=301]
 
# add .php to access file, but don't redirect
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteCond %{REQUEST_URI} !/$
RewriteRule (.*) $1\.php [L]
 
and the APACHE Engine, is one, but when i do php info it says under commands --without-apache... if that has anything to do with it....
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: implicit flushing

Post by Chris Corbyn »

tecktalkcm0391 wrote:but when i do php info it says under commands --without-apache... if that has anything to do with it....
It does. PHP is not compiled as an apache module so apache can't control it. It must be running as CGI I assume.
User avatar
tecktalkcm0391
DevNet Resident
Posts: 1030
Joined: Fri May 26, 2006 9:25 am
Location: Florida

Re: implicit flushing

Post by tecktalkcm0391 »

oh ok... can I add it as a mod somehow?
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: implicit flushing

Post by Chris Corbyn »

Did you install apache and PHP or did someone else? All you need to do is build PHP "--with-apxs2" or "--with-apache2" :) If you didn't install it then you'll need control over php.ini.
User avatar
tecktalkcm0391
DevNet Resident
Posts: 1030
Joined: Fri May 26, 2006 9:25 am
Location: Florida

Re: implicit flushing

Post by tecktalkcm0391 »

hosting company did, but i have access to php.ini and all files on my part of the server, just not like the server config.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: implicit flushing

Post by Chris Corbyn »

tecktalkcm0391 wrote:hosting company did, but i have access to php.ini and all files on my part of the server, just not like the server config.
Cool, so you should be able to just modify implicit_flush in php.ini instead ;)
User avatar
tecktalkcm0391
DevNet Resident
Posts: 1030
Joined: Fri May 26, 2006 9:25 am
Location: Florida

Re: implicit flushing

Post by tecktalkcm0391 »

ok. well what about auto_append_files, but i really only want it for one domain, and like 3 are hosting on the same account...

i guess no way to just add the mod to the config. you'd have to recompile the whole apache server.
User avatar
tecktalkcm0391
DevNet Resident
Posts: 1030
Joined: Fri May 26, 2006 9:25 am
Location: Florida

Re: implicit flushing

Post by tecktalkcm0391 »

actually i can run command line commands if i need to do that to install the module
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: implicit flushing

Post by Chris Corbyn »

You won't be able to install an apache module unfortunately. It sounds like you just need to have a common include() on all pages which starts ob_implicit_flush(). How are your pages laid out? Do they all go via a central file which includes other pages or are they all in separate files?
User avatar
tecktalkcm0391
DevNet Resident
Posts: 1030
Joined: Fri May 26, 2006 9:25 am
Location: Florida

Re: implicit flushing

Post by tecktalkcm0391 »

they are all in separate files, and I was going to use auto_prepend_file to get the same includes on the pages, but I can't do that, so I guess I just need to copy and paste a code to the top of every page. :banghead:
Post Reply