欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

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

程序员文章站 2022-05-25 10:19:30
...

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

回复内容:

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

'.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发起.

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

ajax。。

相关标签: php discuz