|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #18022 fopen does not work with php://stdin anymore
Submitted: 2002-06-27 14:51 UTC Modified: 2002-09-25 09:30 UTC
From: monte at ispi dot net Assigned: wez (profile)
Status: Closed Package: Filesystem function related
PHP Version: 4.2.1 OS: Solaris 8 Sparc
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: monte at ispi dot net
New email:
PHP Version: OS:


 [2002-06-27 14:51 UTC] monte at ispi dot net
This used to work in PHP 4.0.6:

cat test.txt| php -q stdin.php
DEBUG: I have line one
DEBUG: I have line two
DEBUG: I have line three
DEBUG: I have line four
DEBUG: I have line five
DEBUG: I have line six
DEBUG: done



$fp = fopen('php://stdin','r');

while(!feof($fp)) {
	$line = fgets($fp,4096);
	echo "DEBUG: I have line $line";


echo "DEBUG: done\n";

Now in PHP 4.2.1, it does not work, it only prints the first line of the input. I tried setting allow_url_fopen = On but that did not make a difference.

This DOES work however:


$fp = popen('cat /dev/fd/0','r');

while(!feof($fp)) {
	$line = fgets($fp,4096);
	echo "DEBUG: I have line $line";


echo "DEBUG: done\n";

Here is a entry from the mailing list that may be of help.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2002-07-01 15:15 UTC]
Dupe of #16048
 [2002-08-23 22:03 UTC]
The other report didn't get any feedback so I'm opening this one. Seems to be real problem, at least I couldn't get neither of these scripts to work.. (or I misunderstood what I shoud pass them? :)

 [2002-08-23 22:05 UTC]
Nevermind..I should have read the report twice before replying. The first script works fine for me when using 
PHP 4.3.0-dev (CLI).

Can you please try it yourself too?

 [2002-08-24 05:55 UTC]
Could you check main/php_config.h and see if HAVE_FLUSHIO
is defined?
I think that might be the cause of the problem (and that
this will also be reproduceable with streams in HEAD). 
 [2002-08-25 07:04 UTC]
I've committed a potential fix for HEAD; I'm not sure if
this can be fixed properly in PHP 4.2.x.
Please verify if the latest unstable snapshot now works
for you.
 [2002-09-21 02:02 UTC]
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.

 [2002-09-24 16:12 UTC]
I'm keeping this open, as I'm working with someone to verify if the fix I comitted to HEAD is actually working...
 [2002-09-25 09:30 UTC]
This bug has been fixed in CVS.

In case this was a PHP problem, snapshots of the sources are packaged
every three hours; this change will be in the next snapshot. You can
grab the snapshot at
In case this was a documentation problem, the fix will show up soon at

In case this was a website problem, the change will show
up on the site and on the mirror sites in short time.
Thank you for the report, and for helping us make PHP better.

PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 13 03:01:29 2024 UTC