PHP生成linux命令行进度条
<?php
$total = 100; for ($i = 1; $i <= $total; $i++) { printf("progress: [%-50s] %d%% Done\r", str_repeat('#',$i/$total*50), $i/$total*100); sleep(1); } echo "\n"; echo "Done!\n";
在命令行执行比较长时间的任务时,需要实时查看进度。所以需要显示进度条
<?php
$total = 100; for ($i = 1; $i <= $total; $i++) { printf("progress: [%-50s] %d%% Done\r", str_repeat('#',$i/$total*50), $i/$total*100); sleep(1); } echo "\n"; echo "Done!\n";
在命令行执行比较长时间的任务时,需要实时查看进度。所以需要显示进度条