Hi,
few minutes ago I was asked by a friend :
"How can I read the user input in CLI?"
He proposed this :

<?php
print "enter:\n";
$r = fread(STDIN, 100);
print $r;
?>

but....the user has to enter EOF (Ctrl-Z on Windows, Ctrl-D on *nix). This
is not intuitive.
So after some thinking I created this :

<?php
print  "enter:\n";
fscanf($STDIN, "%d\n",$r); //reading a number
print  $r;
?>

I haven't found an example about that issue on the CLI SAPI page.

Thanks,
Andrey


-- 
PHP Documentation Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to