php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #5645 filesize is always 1 byte short
Submitted: 2000-07-17 15:14 UTC Modified: 2000-07-18 00:50 UTC
From: jandeluyck at gmx dot net Assigned:
Status: Closed Package: Misbehaving function
PHP Version: 4.0.1pl2 OS: FreeBSD / Win32
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: jandeluyck at gmx dot net
New email:
PHP Version: OS:

 

 [2000-07-17 15:14 UTC] jandeluyck at gmx dot net
when calling the following: 
$str_of_file = "blah.txt"; // file is 500bytes
$file = fopen($str_of_file);
fgets($file,filesize($str_of_file)); // i only get the 499 first characters of the file!

So there seems to be a problem.

Tested on Win32 (WinNT 4 / 2000) platforms as on FreeBSD 3.0-RELEASE.

the Win32 binary was the one supplied on the PHP site, running on an Apache 1.3.12.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-07-18 00:42 UTC] joey at cvs dot php dot net
RTMF, please:


                 string fgets (int fp, int length)

                 Returns a string of up to length - 1 bytes read from the file pointed to by fp. Reading ends when length - 1 bytes have been read
 [2000-07-18 00:50 UTC] sterling at cvs dot php dot net
PS:  fread is what your looking for.
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Thu Oct 08 22:00:01 2026 UTC