|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #60464 fseek documention incorrect
Submitted: 2011-12-07 22:05 UTC Modified: 2011-12-08 00:10 UTC
From: df1986 at aol dot com Assigned: frozenfire (profile)
Status: Not a bug Package: Filesystem function related
PHP Version: Irrelevant OS: All
Private report: No CVE-ID: None
 [2011-12-07 22:05 UTC] df1986 at aol dot com
From manual page:
Docs say fseek returns -1 on error, actually returns false.

Test script:
//Invalid resource
echo json_encode(fseek('', 52));//outputs false
//Dangling resource
$f = fopen('somefile', 'r');//to get a valid resource
fclose($f);//to make it dangle
echo json_encode(fseek($f, 52));//outputs false


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2011-12-07 23:33 UTC]
Automatic comment from SVN on behalf of frozenfire
Log: Fixed return value. Closed bug #60464.
 [2011-12-07 23:34 UTC]
-Status: Open +Status: Closed -Assigned To: +Assigned To: frozenfire
 [2011-12-07 23:34 UTC]
This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at

 For Windows:
Thank you for the report, and for helping us make PHP better.

By the way, don't use json_encode for debugging. It's bound to screw you up. Use 
var_dump instead.
 [2011-12-07 23:56 UTC]
I think the docs were actually correct here. fseek will return -1 if the seek 
fails, and 0 upon success. It will return false in the case of invalid arguments, 
such as the example below.
 [2011-12-08 00:05 UTC]
Yeah, you're actually right mfonda. Looking back at the sources, that actually 
makes more sense. Normally when I see only two return statements it's a "false on 
failure" situation, but in this case I suppose the RETURN_LONG would provide 
different results based on the internal function it calls.

I'll revert my change.
 [2011-12-08 00:09 UTC]
Automatic comment from SVN on behalf of frozenfire
Log: Reverting previous commit, which was mistaken. Bug #60464.
 [2011-12-08 00:10 UTC]
-Status: Closed +Status: Bogus
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sun Jan 17 01:01:23 2021 UTC