You Are Here Home > How to clean the screen with PHP in Linux (cls, Linux, PHP)
Resource Index Web Directory

How to clean the screen with PHP in Linux (cls, Linux, PHP)

Here is the trick, in your script use:

system("clear");

To make it work on both Windows and Linux:

if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN')
   system("cls");
else
   system("clear");

I hope this helps someone.

How to clean the screen with PHP in Linux (cls, Linux, PHP)
Filed under: Operating Systems,PHP,Programming   Posted by: Codehead
Do you have any questions? ask here.




2 Comments »

  1. William:
     

    Please please please don’t do that :P .

    for ($i = 0; $i < ; $i++) { print “\n”; }

    Is way more portable.

    I know it’s not common, but some people will be running PHP on windows.

    Comment

  2. Codehead:
     

    William, thanks for your comment but with all respect I disagree…

    The code I posted can check for the platform and use “cls” or “clear” and your code won’t produce the desired effect for me.

    Comment

RSS feed for comments on this post. TrackBack URL

Leave a comment