Bug #8515 Updated: Add function to read from stdin
| From: | jimw@php.net | Date: | Sun, 10 Feb 2002 04:18:22 +0000 |
| Subject: | Bug #8515 Updated: Add function to read from stdin | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-21@lists.php.net to get a copy of this message | ||
ID: 8515
Updated by: jimw@php.net
Reported By: ptuasca@hotmail.com
-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] ptuasca@hotmail.com
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