Discuz!安装时这个安装进度是如何实现的?

发布于 2022-09-01 17:53:41 字数 121 浏览 17 评论 0

如图图片描述

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

不如归去 2022-09-08 17:53:41
<?php
// php -S 127.0.0.1:8080 -t /www
// http://127.0.0.1:8080/BubbleSort.php
header('Content-Type: text/html; charset=utf-8');
ob_start();
$array = array(0,1,2,3,4,5,6,7,8,9);
$size = count($array);
for ($i=0;$i<$size;$i++) {
    print_r($array);
    for ($j=0;$j<$size-1-$i;$j++) {
        if ($array[$j] < $array[$j+1]) {
            $temp = $array[$j];
            $array[$j] = $array[$j+1];
            $array[$j+1] = $temp;
        }
    }
    echo '<br />'.str_repeat(' ', 1024*4);
    ob_flush();
    flush();
    sleep(1);
}
echo 'Done.';
ob_end_flush();

每隔1秒显示1行:

Array ( [0] => 0 [1] => 1 [2] => 2 [3] => 3 [4] => 4 [5] => 5 [6] => 6 [7] => 7 [8] => 8 [9] => 9 )
Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5 [5] => 6 [6] => 7 [7] => 8 [8] => 9 [9] => 0 )
Array ( [0] => 2 [1] => 3 [2] => 4 [3] => 5 [4] => 6 [5] => 7 [6] => 8 [7] => 9 [8] => 1 [9] => 0 )
Array ( [0] => 3 [1] => 4 [2] => 5 [3] => 6 [4] => 7 [5] => 8 [6] => 9 [7] => 2 [8] => 1 [9] => 0 )
Array ( [0] => 4 [1] => 5 [2] => 6 [3] => 7 [4] => 8 [5] => 9 [6] => 3 [7] => 2 [8] => 1 [9] => 0 )
Array ( [0] => 5 [1] => 6 [2] => 7 [3] => 8 [4] => 9 [5] => 4 [6] => 3 [7] => 2 [8] => 1 [9] => 0 )
Array ( [0] => 6 [1] => 7 [2] => 8 [3] => 9 [4] => 5 [5] => 4 [6] => 3 [7] => 2 [8] => 1 [9] => 0 )
Array ( [0] => 7 [1] => 8 [2] => 9 [3] => 6 [4] => 5 [5] => 4 [6] => 3 [7] => 2 [8] => 1 [9] => 0 )
Array ( [0] => 8 [1] => 9 [2] => 7 [3] => 6 [4] => 5 [5] => 4 [6] => 3 [7] => 2 [8] => 1 [9] => 0 )
Array ( [0] => 9 [1] => 8 [2] => 7 [3] => 6 [4] => 5 [5] => 4 [6] => 3 [7] => 2 [8] => 1 [9] => 0 )
Done.

打开输出控制缓冲,不断的ob_flush();flush();,就可以在一个PHP请求内不断地输出内容,这个请求你可以通过AJAX发起.

信仰 2022-09-08 17:53:41

使用chrome浏览器,按F12看数据包。
实现的方法有很多种,可以用ajax、也可以用websocket。具体可以看discuz的代码。

荭秂 2022-09-08 17:53:41

ajax。。

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文