
Das Thema der Konsole … fortsetzend
Der einfache Fortschritt-Bar auf пхп … =)
<? 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"; } } ?>
Die Verbannungen, wo es айти diese Klasse möglich ist:
phpclasses.org





CharnaD
13 Dek, 2008
Ich wollte allen bei mir auf хостинге CLI die Anlage machen, und dort ist es verboten ((
Alex Snet
14 Dek, 2008
CharnaD, ich kann den anbieten.
ВПС, wenn es … notwendig ist
0utPunk
17 Dek, 2008
Genug wollte интесный die Klasse, seit langem selbst schreiben, ja ist) nicht dazugekommen Kaum wird nützlich sein, unbedingt.
Alex Snet
17 Dek, 2008
Ich werde froh sein, wenn = helfen wird)
Wenn dass, so kommen Sie öfter. Bald werde ich сурцы ausstellen, wie kompliziert das Matt die Berechnungen und so weiter zu bearbeiten. =). =)