PHP loop; how to print each result and delay it for a second before echoing another result?

前端 未结 2 853
独厮守ぢ
独厮守ぢ 2020-12-04 02:57

this is my first question here on stackoverflow, I just curious.. is it possible to delay loop in PHP ? I\'m trying to print each result to browser and pause the script usin

2条回答
  •  攒了一身酷
    2020-12-04 03:32

    PHP executes and renders its output completely before the page renders its content. So no, you can't delay the PHP loop like you want.

    You could and should do this with javascript. If you need information from the server printed on delay like this, you can use AJAX to pull the information from the server as it becomes available.

提交回复
热议问题