Snippet Name: Prompt user at command line
Description: From the command line mode, prompt a user for keyboard input.
Comment: (none)
Language: PHP
Highlight Mode: PHP
Last Modified: February 27th, 2009
|
<?PHP
ECHO "Give me your name: ";
$data = FOPEN("php://stdin", "rb");
WHILE (1==1) {
$chunk = FREAD($data, 1);
IF ($chunk == "\n" || $chunk == "\r") BREAK;
$input .= $chunk;
}
FCLOSE($data);
ECHO "Hello $input!\n";
?> |