php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #7960 fopen or fclose troubles with 'php://stdin'
Submitted: 2000-11-24 04:57 UTC Modified: 2001-10-19 08:01 UTC
From: p dot pastori at acsys dot it Assigned:
Status: Closed Package: Filesystem function related
PHP Version: 4.0.3pl1 OS: WIN32, WINNT, IRIX
Private report: No CVE-ID: None
 [2000-11-24 04:57 UTC] p dot pastori at acsys dot it
<?php
/* fopen bug ??? */
function ask($prompt = '', $mxin = 256) {
	$ret = false;
	print($prompt);
	$ifd = fopen('php://stdin', 'r');
	if ($ifd) {
		$ret = fgets($ifd, $mxin);
		if (! fclose($ifd)) print("FCLOSE FAILED\r\n");
	}
	return $ret;
}

if ($rep = ask()) print($rep);
/*
 * next ask call causes under WIN32 WIN98 Second Edition:
 *[23-Nov-2000 22:51:02] PHP Warning:  fopen("php://stdin","r") - No error in fopenbug.php on line 6
 * under IRIX 6.5 (6.5.8m):
 *[24-Nov-2000 10:35:21] PHP Warning:  fopen("php://stdin","r") - Bad file number in fopenbug.php on line 6
 * and under WINNT 4.0 Service Pack 6:
 *[24-Nov-2000 10:49:34] PHP Warning:  fopen("php://stdin","r") - No error in fopenbug.php on line 6
 */
if ($rep = ask()) print($rep);
?>

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-10-19 08:01 UTC] sander@php.net
Works fine for me on Win2K, using 4.0.7RC3. You should upgrade to a newer version. Reopen if the problem still exists.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 06:01:30 2024 UTC