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
 [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: Wed Oct 30 22:01:28 2024 UTC