forked from inhere/php-console
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprogress_bar.php
More file actions
31 lines (24 loc) · 1.03 KB
/
Copy pathprogress_bar.php
File metadata and controls
31 lines (24 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?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";