|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #13086 fread design flaw
Submitted: 2001-08-31 19:24 UTC Modified: 2001-08-31 19:28 UTC
From: clarkbattle at hotmail dot com Assigned:
Status: Closed Package: Feature/Change Request
PHP Version: 4.0.6 OS: win2k
Private report: No CVE-ID: None
 [2001-08-31 19:24 UTC] clarkbattle at hotmail dot com
This is more of a design flaw than a bug.  In C the fread() function returns the number of bytes read.  In php it returns the string read.  The C version is better.  If you are reading binary data from a remote HTTP source and you need to know how much data you have read it is impossible with the PHP version.  You cant read in a chunk then do a strlen() on the chunk because its binary and may contain null chars.  read() seems to have the right interface but its experimental and only for sockets.  


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2001-08-31 19:28 UTC]
You mistakenly assume that the PHP strlen() function will stop counting at a NUL.  That is not the case.  It will correctly tell you the number of bytes, including NULs in a string.
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Mon Jul 22 03:01:26 2019 UTC