[PHP-DOC] #21428 [NEW]: additional example for CLI SAPI page From: andrey <email protected>
Date: 01/05/03

From: andrey <email protected>
Operating system: all
PHP version: 4.3.0
PHP Bug Type: Documentation problem
Bug description: additional example for CLI SAPI page

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

-- 
Edit bug report at http://bugs.php.net/?id=21428&edit=1
-- 
Try a CVS snapshot:         http://bugs.php.net/fix.php?id=21428&r=trysnapshot
Fixed in CVS:               http://bugs.php.net/fix.php?id=21428&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=21428&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=21428&r=needtrace
Try newer version:          http://bugs.php.net/fix.php?id=21428&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=21428&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=21428&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=21428&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=21428&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=21428&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=21428&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=21428&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=21428&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=21428&r=gnused

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