Making PHP clear the screen

Problems with the Windows version of XAMPP, questions, comments, and anything related.

Making PHP clear the screen

Postby lolio » 27. December 2008 21:18

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;

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?
Posts: 3
Joined: 27. December 2008 21:12

Re: Making PHP clear the screen

Postby Sharley » 28. December 2008 02:37

Try posting this in the PHP forum as it may be quicker and there are some English speakers who visit that forum who may be able to help.

BTW don't try and machine translate into German or they will not understand it. ;)
Good luck.
User avatar
AF Moderator
Posts: 3316
Joined: 03. October 2008 05:10
Location: Yeppoon, Australia Time Zone: GMT/UTC+10
Operating System: Win 7 Pro 32bit/XP Pro SP3

Re: Making PHP clear the screen

Postby lolio » 28. December 2008 03:19

OK done, thanks.
Posts: 3
Joined: 27. December 2008 21:12

Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 42 guests