php.net |  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
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: df1986 at aol dot com
New email:
PHP Version: OS:

 

 [2011-12-07 22:05 UTC] df1986 at aol dot com
Description:
------------
---
From manual page: http://www.php.net/function.fseek#refsect1-function.fseek-returnvalues
---
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


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-12-07 23:33 UTC] frozenfire@php.net
Automatic comment from SVN on behalf of frozenfire
Revision: http://svn.php.net/viewvc/?view=revision&revision=320620
Log: Fixed return value. Closed bug #60464.
 [2011-12-07 23:34 UTC] frozenfire@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: frozenfire
 [2011-12-07 23:34 UTC] frozenfire@php.net
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
http://snaps.php.net/.

 For Windows:

http://windows.php.net/snapshots/
 
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] mfonda@php.net
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] frozenfire@php.net
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] frozenfire@php.net
Automatic comment from SVN on behalf of frozenfire
Revision: http://svn.php.net/viewvc/?view=revision&revision=320623
Log: Reverting previous commit, which was mistaken. Bug #60464.
 [2011-12-08 00:10 UTC] frozenfire@php.net
-Status: Closed +Status: Bogus
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 03 08:01:34 2025 UTC