php flush not working
tame4tex said 1 year, 1 month ago:
I have an ultimate shared windows web hosting account.
I am trying to get php flush to work but am having no luck.
Here is the code I am using:
<?php
function flush_buffers(){
ob_end_flush();
ob_flush();
flush();
ob_start();
}
ob_start();
echo(str_repeat(‘ ‘,10000));
echo “starting…
n”;
for($i = 0; $i < 5; $i++) {
flush_buffers();
print “$i
n”;
flush_buffers();
sleep(2);
}
flush_buffers();
print “DONE!
n”;
?>
The browser shows that the page is loading and no output is displayed until the page is fully loaded.
Any advice would be appreciated.
nathantf said 1 year, 1 month ago:
@tame4tex
If you are using a Windows hosting plan, that script may not work. There are also browsers that will not display content until it is all available. I would contact our support team to ensure PHP is functioning properly on your account.
Nathan
emmets said 1 year, 1 month ago:
I have this same issue, and it is new since I moved up to php 5.3.6. For the browser, I use Firefox 11.0 and IE 9.
I have two Linux hosting plans with godaddy. One is on php 5.3.6 and one is on 5.2.14
The below code runs fine on 5.2.17. The number prints every half second until the script finishes. On the newer hosting plan which I’ve configured for 5.3.6, it will not work. It loads for a while, then flushes the entire output at once after the script is done. No intermediate output.
I’ve read a ton of posts about how to do flushing, stuff that must be in php.ini, minimum character outputs, but haven’t been able to solve this. Can anyone help me?
Thanks,
emmets
<?php
$i = 0;
while ($i<=10)
{
echo “i=$i “;
flush();
echo(str_repeat(‘ ‘,1024));
usleep(500000);
$i++;
}
?>
adamr said 1 year ago:
@tame4tex @emmets
You should have no problem using PHP flush in our Legacy hosting environment. I will be reviewing the compatibility of PHP flush in the 4GH hosting environment with our hosting guys. I will post an update here as soon as possible.
-Adam
adamr said 1 year ago:
@adamr
At this time, PHP flush is not supported in the 4GH shared hosting environment. PHP flush is currently only compatible with our Legacy Linux hosting plans and our virtual dedicated/dedicated Linux server options. If any information about supporting this feature in the 4GH environment comes to light in the future, I will post an update here.
-Adam
assasite said 5 months ago:
I have experienced the same problem on my site (web hosting – linux/apache). It works on another site I support, but not on GoDaddy.
The program I used to test this is:
<?php
ob_start();
for ($i = 1; $i < 21; $i++) {
echo “$i – string 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890
“;
ob_flush();
flush();
sleep(1);
}
?>
On my other site, it starts to display the results after about 3 seconds and then displays a new line every second. On GoDaddy it waits 15 seconds and then displays everything at once.
I would like to make this work as it significantly improves the feel of response time as some output is displayed immediately.
adamr said 5 months ago:
@assasite
For PHP flush support, you’ll need to move to a Legacy plan or a VPS plan. Here’s a link to each of the plans:
Legacy Hosting Plans
https://www.godaddy.com/hosting/hosting.aspx
Moving from 4GH to a Compatible Hosting Plan
VPS Plans
http://www.godaddy.com/hosting/vps-hosting.aspx
-Adam
assasite said 5 months ago:
Thank you for the prompt response. I believe I am already on a Legacy Plan. The account details page says “Hosting – Web – Deluxe – Linux – US”.
I can see that output buffering works as the ob_get_level and ob_get_length commands show the output buffers changing in my programs.
Rick
adamr said 5 months ago:
@assasite
Our ‘Web’ hosting plans are hosted in the 4GH grid environment. This plan will not support PHP flush. At this time, I still do not have any information regarding the future offering of PHP flush support in the 4GH/grid environment.
-Adam
shrimpwagon said 4 months, 1 week ago:
So… does any of the PHP output buffering work? Nothing is working for me
ob_start()
ob_flush()
ob_clean()
assasite said 4 months, 1 week ago:
I found that it does not work on the hosting plan I am using (Web – Deluxe – Linux).
Rick
adamr said 4 months ago:
@shrimpwagon
You would need to move to a Legacy hosting plan. It will not work in our Web/Grid/4GH environment.
-Adam
8 min expected wait time