简体   繁体   中英

PHP passthru('cls') not working

I'm a newbie for PHP in command line. I'm using windows and I want to clear the screen in command line. I've searched it and found this code

<?php passthru('cls'); ?>

But this code instead of clearing the screen, it shows this character '♀'. I've also tried using shell_exec and exec , but they failed. Did I do anything wrong? How do I fix this?

Thanks :D

After much searching, I finally found an answer that works for me in Windows 7 that relies on ANSI (like the comments above):

echo chr(27)."[H".chr(27)."[2J";

This works for me in the standard console because I installed Ansicon , which appears to be what you're missing... if you're having trouble you might also want to try Console2 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM