How to do Press Any Key To Continue with php.exe

JDS <[email protected]>
Newsgroups gmane.comp.php.windows
Message-ID <[email protected]>
I am wondering if there is a better way to do this than what I have come up with. The 
first example waits for the ENTER key to be pressed, but any other characters you press 
show up on the screen

The second method works with any key being pressed, but uses exec().

Any other suggestions? Basically I am wanting the console window to stay open at the end 
of the script so the user can read what was displayed in the window before the console 
window closes down.

Thanks

 > php test.php

<?php
//test. php

//Not the most elegant, but it works!
echo "\n\n";
echo "Press ENTER to continue... ";
$handle = fopen("php://stdin","r");
$getLine = "";
while ($getLine == ""):
     $getLine = fgets($handle);
endwhile;

//A little better but uses exec()
echo "\n\n";
echo "Press ANY KEY to continue... ";
exec("pause");

?>

-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.