php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #3895 fopen / multiple files
Submitted: 2000-03-22 09:31 UTC Modified: 2002-09-30 20:04 UTC
From: c dot lukas at eit dot de Assigned:
Status: Not a bug Package: Other
PHP Version: 3.0.14 OS: linux
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: c dot lukas at eit dot de
New email:
PHP Version: OS:

 

 [2000-03-22 09:31 UTC] c dot lukas at eit dot de
using the following lines of code:

  $fd=fopen("$file1","r") || die ("Internal Error\n");
  $content=fread($fd,filesize($file1));
  echo "$content</br>";
  fclose("$fd");

  $fh=fopen("$file2","r") || die ("Internal Error\n");
11  $content=fread($fh,filesize($file2));
  echo "$content</br>";
13  fclose($fh);

results in:
Text from file1 

Warning: Unable to find file identifier 1 in /usr/local/htdocs/test.php3 on line 11

Warning: Unable to find file identifier 1 in /usr/local/htdocs/test.php3 on line 13

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-09-30 20:04 UTC] hholzgra@php.net
you have to use "or" instead of "||" here

the || resulted in 1 for both assigments
and just by chance the first fopen also
returned resource id 1, while the second
returned 2, so first handle works but 
second fails as resource id 1 is already closed

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 11:01:30 2024 UTC