Unbuffered Reads
| From: | Steven James Samuel Stapleton | Date: | Sun, 05 Jun 2005 07:29:53 +0000 |
| Subject: | Unbuffered Reads | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-216404@lists.php.net to get a copy of this message | ||
Is there any way to perform an unbuffered read in PHP when reading from STDIN?
I.E. if I have the code
---------------------
$chr = "";
while(!feof(STDIN))
{
$chr = fgetc(STDIN); //I could just as easily do fread(STDIN, 1)
if($chr == " ")
break;
}
---------------------
and enter the following string (note this is how you would enter the string in a program to have it have the same value I'd type in):
"this is a test\n"
It will stop reading at the newline, and not the first space.
Any ideas?
System Info
Environment: Windows XP Pro (used both the windows and cygwin command lines)
PHP Version: 5.0.3
Thanks
-Jim Stapleton