|
|
show progress in terminal using php - PHP
|
Views : 176
|
|
Tagged in : PHP
|
|
|
Report This Scrap as Inappropriate We request you to choose the appropriate categroy and subcategory that suits your
objectionable concern about the scrap, So that our team can review and find out whether it violates our Guidelines or the
scrap is not suitable for all viewers.
|
Hi,
While we doing any big tasks in the background, some time we're interested to know how much it is completed and how much time it'll
take to complete the whole task.
Most of the time we do run these process in terminal as a background process. so that time we need to know above said things. Following
code will show you process 1 to 100 in terminal.
This is only a sample code, you've to update it according to your reqirements,
echo "Progress : "; // 5 characters of padding at the end
for ($i=0 ; $i<=100 ; $i++) {
echo "\033[5D"; // Move 5 characters backward
echo str_pad($i, 3, ' ', STR_PAD_LEFT) . " %"; // Output is always 5 characters long
sleep(1); // wait for a while, so we see the animation
}
Run this program in terminal by giving absolute path like,
/opt/lampp/bin/php /opt/lampp/htdocs/labs/index.php |
|
By Guna, On - 2011-10-10 |
|
|
|