#27461 [Opn->Bgs]: fread($fp,0) generates warning
| From: | derick@php.net | Date: | Tue, 02 Mar 2004 17:39:59 +0000 |
| Subject: | #27461 [Opn->Bgs]: fread($fp,0) generates warning | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-55789@lists.php.net to get a copy of this message | ||
ID: 27461
Updated by: derick@php.net
Reported By: mark at quarella dot co dot uk
-Status: Open
+Status: Bogus
Bug Type: Filesystem function related
Operating System: Linux
PHP Version: 4.3.5RC3
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
This was a deliberate change.
Previous Comments:
------------------------------------------------------------------------
[2004-03-02 11:58:42] mark at quarella dot co dot uk
Description:
------------
fread($handle, 0) generates a warning where it did not in earlier
versions.
This typically occurs in situations where the filesize is calculated:
fread($handle, filesize($filename));
(where $handle is the result of opening file $filename, and $filename
is the name of a zero-byte file)
Reproduce code:
---------------
// Taken from fread documentation, will generate WARNING
// if something.txt exists and is empty (0 bytes)
// get contents of a file into a string
$filename = "/usr/local/something.txt";
$handle = fopen($filename, "r");
$contents = fread($handle, filesize($filename));
fclose($handle);
Expected result:
----------------
Would expect $contents == '', no errors or warnings
Actual result:
--------------
Warning: fread(): Length parameter must be greater than 0. in xx on
line yy
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=27461&edit=1