php.net |  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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
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

stdin.php
---------

<?php

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

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

fclose($fp);

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:

<?php

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

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

pclose($fp);

echo "DEBUG: done\n";
?>



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

http://marc.theaimsgroup.com/?l=php-general&m=101428004729977&w=2

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-07-01 15:15 UTC] sander@php.net
Dupe of #16048
 [2002-08-23 22:03 UTC] sniper@php.net
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] sniper@php.net
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?

http://snaps.php.net/php4-latest.tar.gz

 [2002-08-24 05:55 UTC] wez@php.net
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] wez@php.net
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] sniper@php.net
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] wez@php.net
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] wez@php.net
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 http://snaps.php.net/.
 
In case this was a documentation problem, the fix will show up soon at
http://www.php.net/manual/.

In case this was a PHP.net website problem, the change will show
up on the PHP.net 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: Thu Mar 28 08:01:28 2024 UTC