NYCPHP Meetup

NYPHP.org

[nycphp-talk] CLI output question

Scott Mattocks scott at crisscott.com
Wed Aug 17 13:12:29 EDT 2005


David Mintz wrote:

> How do you print to STDOUT so that what you're printing ~replaces~ what
> you previously printed to STDOUT, instead of appending? You know, like the
> way PEAR installer shows you download progress with a btye counter that
> keeps updating itself?

When you write a new line use \r instead of \n. This will take you back 
to the begining of the line where you can output new information. You 
have to explicitly overwrite any old characters for them to go away. If 
the second set of output is shorter than the first, the extra characters 
from the first line will still be seen.

-- 
Scott Mattocks
scott at crisscott.com
http://www.crisscott.com
http://pear.php.net/user/scottmattocks



More information about the talk mailing list