ID: 8515
Updated by: [EMAIL PROTECTED]
Reported By: [EMAIL PROTECTED]
-Status: Open
+Status: Closed
Bug Type: Feature/Change Request
Operating System: All
PHP Version: 4.0.4
New Comment:
you can just call fgets() or fscanf() on the file pointer from opening
'php://stdin'.
Previous Comments:
------------------------------------------------------------------------
[2001-01-02 09:47:04] [EMAIL PROTECTED]
Hi folks.
Could you add a function to a next release that reads from stdin? It
would make it easier to write console scripts...
A function with the same prototype of C scanf() would be great.
Also, a section in the manual regarding "How to use PHP to write
shell/console scripts" would be nice (it took me a whole year to figure
out that I could open stdin all the time...)
Currently, I use the following (do yo remember Pascal?):
Function Readln(&$INPUT){
$fp = fopen("php://stdin","r");
while (!feof($fp)) {
$BUFFER = fgetc($fp);
$INPUT .= $BUFFER;
if ($BUFFER == "\n")
break;
}
fclose($fp);
}
And by the way, keep up the good job with PHP! Congratulations!
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=8515&edit=1