Making PHP clear the screen

Alles, was PHP betrifft, kann hier besprochen werden.

Making PHP clear the screen

Postby lolio » 28. December 2008 03:20

Reposted in here on the advice of Sharley.

I'm trying to make a CLI program using PHP but want it to have a nice menu to be easy to use. However In order to do this I need to be able to clear the screen.
I have tried the following few bits of code and none of them seem to work under XAMPP.
Code: Select all
exec('command /C cls');

passthru('command /C cls');

function clearscreen($out = TRUE) {
    $clearscreen = chr(27)."[H".chr(27)."[2J";
    if ($out) print $clearscreen;
    else return $clearscreen;
}
clearscreen();

All that happens is some weird characters get displayed on screen. I've even tried having a file called clearscreen.cmd which works fine when run from the command line but when called from PHP it too just displays the same weird characters. I've had a look through my php.ini file but can't find anything that would seem to cause this. This happened on XAMPP 1.6.8 and still happens now I've updated to 1.7.0.

Does anyone know why this happens and how I can fix it?
lolio
 
Posts: 3
Joined: 27. December 2008 21:12

Re: Making PHP clear the screen

Postby KingCrunch » 28. March 2009 03:41

As a workaround you might insert a bunch of newlines.
Nicht jeder Fehler ist ein Bug ...
KingCrunch
 
Posts: 1724
Joined: 26. November 2005 19:25


Return to PHP

Who is online

Users browsing this forum: No registered users and 9 guests