睡前PHP输出文本

2021-12-22 00:00:00 sleep text php

我想让 PHP 输出一些文本,然后休眠一秒半,然后再输出一些文本.

I want PHP to output some text, then sleep for a second and a half, and then output some more text.

<?php

echo 'Output one.';

usleep(1500000);

echo 'Output two.';

?>

我的问题是所有文本都被同时输出 - 等了 1.5 秒之后.我读过一些关于一个叫做flush的函数——但它似乎不起作用.也许我没有使用它写.任何帮助将不胜感激^^

My problem is that all text is being put out simultaneously - after having waited those 1.5 seconds. I have read something about a function called flush - but it doesn't seem to work. Maybe I'm not using it write. Any help would be appreciated ^^

提前致谢!

推荐答案

看看这个

<?php

ob_start();

echo 'Output one.';
ob_flush();
usleep(1500000);
echo 'Output two.';
ob_flush();

?>

相关文章