php flush not working
You're using ob_flush
without ob_start
, so there is nothing to flush for it.
It also depends on the webserver and proxy and its settings.
You should disable buffering for Nginx (add proxy_buffering off;
to the config file and restart Nginx)
Also, check if your php.ini contains output_buffering = Off
and zlib.output_compression = Off
.
ob_flush () does not work on my server
As you have mentioned that you don't see any value for output_buffering
in your comment, I assume it's turned off in your server.
If you are using your own server, then look for the Configuration File (php.ini) Path
option in your phpinfo
page (which I asked you to create in comments).
Then open that file, find the ;output_buffering = Off
line, and change it to:
output_buffering = 4096
You might need to restart your apache server (or your web server if it's different).
=============================================================
If you are on a shared hosting, most hosting providers allow you add your own configurations by adding a php.ini
file to your public_html
folder.
Create a file named as php.ini
and include output_buffering = 4096
in it, then upload it to your public_html
folder. It should work.
Hope it helps :) Feel free to ask anything if you have any doubts.
PHP flush don't work
This works, but only in a default apache environment:
<?php
ini_set('output_buffering', 0);
ini_set('zlib.output_compression', 0);
if( !ob_get_level() ){ ob_start(); }
else { ob_end_clean(); ob_start(); }
for ($i = 0; $i < 10; $i++) {
//For Nginx we have to reach minimum buffer size,
//so if it is not enough increment output
echo str_pad( $i . '<br>', 1024 + 10, ' ', STR_PAD_RIGHT );
flush();
ob_flush();
sleep(1);
}
Nginx needs more configurations:
usually in /etc/nginx/nginx.conf
gzip off;
proxy_buffering off;
fastcgi_buffer_size 1k; #set buffer to 1k
fastcgi_max_temp_file_size 0;
fastcgi_buffers 128 1k; #set max buffer size to 1k + 128*1k
PHP flush() function not working
My problem was php handler, i was using suphp, now i changed it to fastcgi and problem solved.
ob_implicit_flush(), flush(), ob_flush() - not working on remote server
I didn't take into account nginx, which has it's own output buffer.
I simply added 'header("X-Accel-Buffering: no");' to the top of the php script and it all works fine now.
Related Topics
How to Write Cdata Using Simplexmlelement
Get Min and Max Value in PHP Array
Ternary Operator Left Associativity
How to Use Spl_Autoload() Instead of _Autoload()
Friendship System with Laravel:Many to Many Relationship
How to Delete an Object's Property in PHP
Change Timezone in Lumen or Laravel 5
How to Check If Curl Is Enabled or Disabled
PHP Header(Location: ...): Force Url Change in Address Bar
Manipulate an Archive in Memory with PHP (Without Creating a Temporary File on Disk)
Can PHP Namespaces Contain Variables
Convert Ascii to Utf-8 Encoding
How to Override Trait Function and Call It from the Overridden Function
How to Rename Sub-Array Keys in PHP
How to Get the Previous Url Using PHP