Quick Search:
 
 PHP Code: Prompt user at command line Jump to:  
Category: >> PHP Code >> Prompt user at command line  

<< lastnext >>

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";
 
?>


 
   Home |    Search |    Code Library |    Sponsors |    Privacy |    Terms of Use |    Contact Us © 2003 - 2024 psoug.org