Is it possible in php to exit a loop on a "key press"?
For example continual for loop to exit on key press and to continue executing rest of code so not sigterm, just stop loop and continue?
Is it possible in php to exit a loop on a "key press"?
For example continual for loop to exit on key press and to continue executing rest of code so not sigterm, just stop loop and continue?
What you want to do is read from stdin: http://linux.about.com/library/cmd/blcmdl3_stdin.htm
Here's a tutorial for how to do it in PHP: http://codegolf.com/boards/conversation/view/129
Hope that helps!
Edit: Found a question which answered this much better: PHP CLI: How to read a single character of input from the TTY (without waiting for the enter key)?
Press ctrl+pausebreak keys on your keyboard to stop a loop which is running in PHP command shell.
for Windows, you can use API functions to retrieve keyboard state. The way to call Win32 API functions is described in http://de.php.net/manual/en/ref.w32api.php. The API function you need to call is GetKeyboardState where the result is stored in an array.