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 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: 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

Add a Patch

Pull Requests

Add a Pull Request

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: Thu May 02 15:01:33 2024 UTC