Here is a an extract from some code...
Note that if you want to read more then
one thing from the user, you better not
close STDIN, cause you can only open it once.
Here's the code it may not work without
some fixing... dunno:
-? php
function Readln(&$INPUT){
// $fp = fopen("php://stdin","r");
while (!feof(STDIN)) {
$BUFFER = fgetc(STDIN);
$INPUT .= $BUFFER;
if ($BUFFER == "\n")
break;
}
// fclose($fp);
}
set_time_limit(0);
## Don't time out in interactive console mode.
define ("STDIN", fopen("php://stdin","r"));
## Make STDIN a global thing.
While (1)
{
$UserInput = preg_replace("/\n/","",$UserInput);
$UserInput = preg_replace("/\r/","",$UserInput);
switch (strtolower($UserInput)) {
case "exit":
case "quit":
echo "goodbye!";
break 2; // exit switch and main loop
/* do some other stuff ... */
}
Readln($UserInput);
}
fclose (STDIN);
?-
Northern.CA ===--
http://www.northern.ca
Canada's Search Engine
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]