
Continuing a console theme …
Simple progress-bar on пхп … =)
<? class progressbar { private $escapeSequence = "\033 [%sm"; "\033[%sm"; private $text = "; ''; private $steps = 0; 0; private $delim = "; ''; private $step = 0; 0; private $maxchars = 70; 70; public function __ construct ($steps=100, $text = ", $ delim = ' # ', $ maxchars=70)$steps=100,$text='',$delim='#',$maxchars=70) { $this-> steps = abs ($steps); = abs($steps); $this-> step = 0; = 0; $this-> text = $text; = $text; $this-> delim = $delim; = $delim; $this-> maxchars = $maxchars; = $maxchars; $this-> draw ();(); } public function update ()) { $this-> step ++;++; $this-> redraw ();(); } private function draw ()) { print $this-> text. ' [';text.' ['; $proc = round (($this-> step / $ this-> steps) *100,0);(($this->step/$this->steps)*100,0); $complete = $proc. ' % complete ';.'% complete'; $isuse = strlen ($complete) + 4 + strlen ($this-> text);($complete) + 4 + strlen($this->text); $max = $this-> maxchars - $isuse;->maxchars - $isuse; $dash = round ($max * ($ proc/100) +1);($max*($proc/100)+1); $free = $max - $dash; - $dash; if ($dash> 0) print str_repeat ($this-> delim, $dash);>0) print str_repeat($this->delim,$dash); if ($free> 0) print str_repeat (' - ', $ free);>0) print str_repeat('-',$free); print '] '. $ complete;$complete; } private function redraw ()) { $this-> toPos ();(); $this-> draw ();(); } private function toPos ($column = 1) $column = 1 ) { echo "\033 [{$column} G";G"; } } ?>
References where it is possible айти this class:
phpclasses.org





CharnaD
13 Deck, 2008
I all wanted at myself on a hosting to make CLI the appendix, and there it is impossible ((
Alex Snet
14 Deck, 2008
CharnaD, I can offer the.
ВПС if it is necessary …
0utPunk
17 Deck, 2008
There is enough интесный a class, for a long time wished to write itself, yes was not in time) As soon as it is useful, I will try necessarily.
Alex Snet
17 Deck, 2008
I will be glad, if will help =)
If that come more often. I will soon lay out сурцы how to process difficult a floor-mat calculations and so on. =). =)