UK WEB HOSTING FORUM FOR DISCUSSION ON WEB HOSTING SERVICE AND SUPPORT
LINUX HOSTING WINDOWS HOSTING PACKAGES SHOPPING CART OSCOMMERCE ZEN CART AGORA
ECOMMERCE HOSTING ASP MSSQL FRONTPAGE HOSTING PHP MYSQL HOSTING DISCUSSION FORUM
CPANEL RESELLER HOSTING DEDICATED SERVER VPS HOSTING PLESK VIRTUOZZO
Quick Search
Your forum announcement here!

  UK Web Hosting | Dedicated Server Windows and Linux VPS Forum > Web Hosting and Domains > PHP Hosting

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-01-2008, 11:00
Junior Member
 
Join Date: Jan 2008
Posts: 11
Default Progressive display

Now I'm baffled.

How come, when you have a slow connection say, or the server is rather busy, that some sites display part of the page, then another bit, and then more, until it's finished?

But when I try:

<html>
<head>
</head>
<body>

Test<br>
</body>
</html>

<?php
$i=1;
while($i <= 5){
echo("Wait " . $i . "<br>");
sleep(1);
$i++;
}
?>

Nothing happens until the whole page processing has finished.
And then it displays the php bit, apparently taking no notice of the </html> etc.

Any idea what's going on here?

Ron
Reply With Quote
  #2 (permalink)  
Old 12-01-2008, 23:33
Rock's Avatar
System Administrator
 
Join Date: Dec 2006
Posts: 518
Thumbs up

Hello Ron, Where are you running this PHP from ? I've had this tested on most our servers [Windows & Linux] & it worked well for me. When run, it started to process the whole page along with the PHP inside, starting from test :
Quote:
Test
Wait 1
Wait 2
Wait 3
Wait 4
Wait 5
Once it was done, the page stopped loading. I doubt this being a network latency issue, hence the timeout on your end.
Please email our support dept, with your complete details, in case you face any similar issue on your account hosted with us, we'd get this fixed for you.
__________________

Rock _a.k.a._ Jack L.

http://www.eUKhost.com
Windows Hosting || Windows Reseller Hosting
Reply With Quote
  #3 (permalink)  
Old 13-01-2008, 07:25
Junior Member
 
Join Date: Jan 2008
Posts: 11
Default

Hello Rock,

Yes it works OK. No problem there.
But what puzzles me is why, when the </html> is met by the browser, it still continues to obey the other html commands.
As far as the browser is concerned the </html> seems to have no significance.

Does Apache feed out the file contents, and php generated html, bit by bit, or does it wait until it's finished all the processing before sending the whole thing?

Ultimately, what I'm after, is to be able to display an html page on the browser, and still let the server php continue processing a long job.
This would enable the user to, say, click a link to go away from the page, but still leave the php on that page processing.

As it stands, it seems that the html in the file only appears on the browser after all php processing has finished.

Ron.
Reply With Quote
  #4 (permalink)  
Old 19-01-2008, 20:50
mephisto's Avatar
Member
 
Join Date: Feb 2007
Location: Darlington
Posts: 99
Send a message via ICQ to mephisto Send a message via MSN to mephisto
Default

I think your talking about flushing the current output to the browser, you need to use output buffering and then flush it to the browser.

eg.

PHP Code:
<?
if (ob_get_level() == 0ob_start();
for(
$i 0$i 10$i++) {
    echo 
"<br/>$i";  // your output
 
    
ob_flush();
    
flush();  // needed ob_flush
    
usleep(50000);// delay minimum of .05 seconds to allow ie to flush to screen
}
?>
Reply With Quote
  #5 (permalink)  
Old 19-01-2008, 20:57
Junior Member
 
Join Date: Jan 2008
Posts: 11
Default

Ah yes that's it.
Many thanks Mephisto.

Apache seems to be set to send at 4096 as default.
So forcing a flush is the thing.

Thanks again.

Ron
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 02:53.

 

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by Web Hosting 3.1.0
Copyright © 2001-2008, eUKhost.com. All rights reserved.

 
Site Map

knowledgebase articles

popular blog categories