开发者

php doesn't update page until finishing loading

开发者 https://www.devze.com 2023-03-04 18:39 出处:网络
I want to write a crawler script with php and it is necessery to show pages which is indexing online. however, php doesn\'t update page real time, sometimes it write a few echos together and wait unti

I want to write a crawler script with php and it is necessery to show pages which is indexing online. however, php doesn't update page real time, sometimes it write a few echos together and wait until finishing loading, someti开发者_开发技巧mes nothing seems in page until finishing loading.

Here is an example about what I'm talking:

<?php
echo '1<br>';
sleep(2);
echo '2<br>';
sleep(2);
echo '3<br>';
sleep(2);
echo '4<br>';
?>

I tried on wamp and lamp and results were same. is there any way to show echos real time?

note: I found an online crawler which has this feature.


Try using flush().

Another, more manual, way is to query the server multiple times via ajax or using something like Comet.


I suggest you use some JavaScript to self refresh the page and it can then be called after each routine to run the necessary php function.

0

精彩评论

暂无评论...
验证码 换一张
取 消