mixed keyb_prompt(string prompt [, string default [, int max_input]]) -- Get input from stdin.
<?php |
This will output:
Enter your name: Jonas Your name is: Jonas |
Published under the terms of the BSD License
<?php
function keyb_prompt($prompt, $default = false, $max=1024) {
if (!isset($GLOBALS['stdin'])) {
$GLOBALS['stdin'] = fopen('php://stdin', 'r');
}
echo "$prompt";
$return = fgets($GLOBALS['stdin'], $max);
if ($return == '') {
return $default;
}
else {
return $return;
}
}
?>
Last updated: Sat Jun 14 20:02:44 CEST 2008