1 Star 3 Fork 26

yg178/php-console

forked from inhere/php-console 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
progress_bar.php 1.03 KB
一键复制 编辑 原始数据 按行查看 历史
<?php
echo "start\n\n";
/*
\r 回到行首
chr 转换为 ASCI 码
*/
$i = 1;
$total = 100;
while ($i <= 100) {
// printf("\rMade some progress, downloaded %2d kb so far", $i);
// echo "\rMade some progress, downloaded $i kb so far";
// printf("\rMade some progress, completed items: %d%% (%d/%d)", ceil(($i/$total) * 100), $i, $total);
$length = $i; // ■ = #
$tfKb = ceil($i*0.95);
// printf("\r[%-100s] %d%% (%2d/%2d kb)", str_repeat('#', $length) . '>', $length, $tfKb, $i * 10);
// mac is not support there are chars.
// printf("\r[%-100s] %d%% (%2d/%2d kb)", str_repeat(chr(22), $length) . '>', $length, $tfKb, $i * 10); // ■
// printf("\r[%-100s] %d%% (%2d/%2d kb)", str_repeat(chr(1), $length) . '>', $length, $tfKb, $i * 10);// ☺
// printf("\r[%-100s] %d%% (%2d/%2d kb)", str_repeat(chr(2), $length) . '>', $length, $tfKb, $i * 10);// ☻
printf("\r[%-100s] %d%% (%2d/%2d kb)", str_repeat(chr(3), $length) . '>', $length, $tfKb, $i * 10);// ♥
usleep(50000);
$i++;
}
echo "end\n";
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
PHP
1
https://gitee.com/hwsyy/php-console.git
git@gitee.com:hwsyy/php-console.git
hwsyy
php-console
php-console
master

搜索帮助