PHP cli progress Bar

This is a simple trick to make your PHP console application more funny

function progress($seconds =10){
$seconds  = (isset($seconds ) and (int)$seconds )  ? $seconds *4 : 40;
echo "\t[+] ".str_repeat("²", $seconds );
for($i=0;$i<=$seconds ;$i++)    {
$fonce = str_repeat("Û", $i);
print "\r\t[+] ".$fonce;
usleep(250000);
}
}

Progress bar will appear by calling the function and number of seconds (10 in my case) :

print progress(10); //print is optional

Comments (1)

MohamedMarch 31st, 2011 at 3:10 pm

nice work. :) ) that’s geek fun ;)

Leave a comment

Your comment