# fread($fp, 0);

- Thread: https://externals.io/message/9620
- Original archive: https://news-web.php.net/php.internals/9620
- Started by Derick Rethans on 2004-04-30T20:18:14+00:00
- Messages: 2
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #9620 — Derick Rethans — 2004-04-30T20:18:14+00:00

URL: https://externals.io/message/9620#9620

Hello,

what was the rationale behind throwing a warning for the snippet in the
topic?

Warning: `fread()`: Length parameter must be greater than 0. in
               /usr/local/lib/php/PEAR/Common.php on line 1296

This breaks often used code where the filesize is 0, like:
	$f = fopen('file', 'r');
	$contents = fread($f, filesize('file'));

And I don't really see the point of throwing a warning here.

Derick

---

## #9621 — Zeev Suraski — 2004-04-30T20:29:19+00:00

URL: https://externals.io/message/9620#9621 · In reply to: #9620

The CVS update read:

Fixed bug #26752 (Silent unterminated loop when length parameter for
 `fgets()`, `fread()` and fgetss() is 0).

(done by Ilia January 2nd this year)

I tend to agree that this was a bad idea, and suggest to restore the old 
check.  Unless I'm missing something, bug #26752 wasn't a bug in PHP but in 
the reporter's code.

Zeev

At 23:18 30/04/2004, Derick Rethans wrote:
>Hello,
>
>what was the rationale behind throwing a warning for the snippet in the
>topic?
>
>Warning: `fread()`: Length parameter must be greater than 0. in
>                /usr/local/lib/php/PEAR/Common.php on line 1296
>
>This breaks often used code where the filesize is 0, like:
>         $f = fopen('file', 'r');
>         $contents = fread($f, filesize('file'));
>
>And I don't really see the point of throwing a warning here.
>
>Derick
