Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 11 of 11
  1. #1
    New Coder
    Join Date
    Jul 2002
    Location
    Queens, NY, USA
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Command to clear screen in PHP?

    Is there a Clear Screen command in PHP? Thanks!
    "Is life not a hundred times too short
    for us to stifle ourselves?"

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Location
    UK
    Posts
    577
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Clear what screen? The browser page?
    Ökii - formerly pootergeist
    teckis - take your time and it'll save you time.

  • #3
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,278
    Thanks
    4
    Thanked 83 Times in 82 Posts
    T.V. Screen? lol
    Spookster
    CodingForums Supreme Overlord
    All Hail Spookster

  • #4
    Mega-ultimate member
    Join Date
    Jun 2002
    Location
    Winona, MN - The land of 10,000 lakes
    Posts
    1,855
    Thanks
    1
    Thanked 45 Times in 42 Posts
    I think they're asking for the command to clear the screen when your using php from the command line. Like clr in DOS or clear in Linux. Is it possible wiht PHP from the command line?

  • #5
    Regular Coder
    Join Date
    Jul 2002
    Location
    Iran
    Posts
    695
    Thanks
    0
    Thanked 0 Times in 0 Posts

  • #6
    New to the CF scene
    Join Date
    Dec 2006
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    clearing on the command line in php

    Hi, using the exec and system commmands might not work,

    but if you use the passthru command, combined with the clear bash command, it WILL work. that is:

    passthru('clear');

    that will clear the screen

  • #7
    Regular Coder ralph l mayo's Avatar
    Join Date
    Nov 2005
    Posts
    951
    Thanks
    1
    Thanked 31 Times in 29 Posts

    Thumbs up

    sweet thread. I installed php5-cgi just to verify this works:

    PHP Code:

    function cls()
    {
        
    array_map(create_function('$a''print chr($a);'), array(27917227915074));

    edit: caveat: only tested in xterm and konsole, but I don't see why it wouldn't work on DOS or a television or an etch-a-sketch.
    Last edited by ralph l mayo; 12-20-2006 at 10:37 PM.

  • #8
    Senior Coder rafiki's Avatar
    Join Date
    Aug 2006
    Location
    Floating around somewhere...
    Posts
    2,042
    Thanks
    19
    Thanked 42 Times in 42 Posts
    Quote Originally Posted by ralph l mayo View Post
    edit: caveat: only tested in xterm and konsole, but I don't see why it wouldn't work on DOS or a television or an etch-a-sketch.
    Quality, havent even heard of an etch-a-sketch for years

  • #9
    New to the CF scene
    Join Date
    Jun 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy

    Quote Originally Posted by ralph l mayo View Post
    sweet thread. I installed php5-cgi just to verify this works:

    PHP Code:

    function cls()
    {
        
    array_map(create_function('$a''print chr($a);'), array(27917227915074));

    Tested on Windows 7, not working!!

    It only shows on screen this: ←[H←[2J

  • #10
    New to the CF scene
    Join Date
    Sep 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I had the same problems. After some hours of searching in the internet, I was sure that there are no good answers, I made some experiments. Luckily experiment 3 worked.

    This works on all Windows Computers. I guess that it will work on Linux and other systems too, as long as the PHP Console is a HTML Console (any Web Browser) and Javascript is on this Browser activated.

    I started this file on my localhost and uploaded the PHP file to my server and started it from there. Both tests did the CLS. I tried it on Windows XP and a friend did a test on Windows 7, and it worked on his Windows 7 too.

    It executes on the client's computer in the PHP file an javascript code.


    <?php

    echo "<script type='text/javascript'>\n";
    echo "document.body.innerHTML = ''";
    echo "</script>";

    ?>
    Last edited by FrankyBKK; 09-16-2012 at 11:54 AM.

  • #11
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,294
    Thanks
    57
    Thanked 523 Times in 510 Posts
    Blog Entries
    5
    That isn't the same thing as what the op was asking 10 years ago Franky. The op was asking how to clear the screen when using php in command line form. PHP is commonly known as a server side language so most people would understand that you can't use it to clear a browser.

    The code you've posted is simply javascript. The fact that you're echoing it out via php doesn't mean that its actually php clearing the browser screen.
    See my new CodingForums Blog: http://www.codingforums.com/blogs/tangoforce/

    Many useful explanations and tips including: Cannot modify headers - already sent, The IE if (isset($_POST['submit'])) bug explained, unexpected T_CONSTANT_ENCAPSED_STRING, debugging tips and much more!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •