睡前PHP输出文本 [英] PHP output text before sleep

查看:32
本文介绍了睡前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();

?>

这篇关于睡前PHP输出文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆