php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #47371 fseek: Description of negative offset use is not clear
Submitted: 2009-02-12 16:27 UTC Modified: 2009-09-04 07:29 UTC
From: sammywg@php.net Assigned:
Status: Closed Package: Documentation problem
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
 [2009-02-12 16:27 UTC] sammywg@php.net
Description:
------------
If you want to use negative fseek offset, it is not enough to use a negative offset as second parameter, also the third parameter must be specified as SEEK_END. The documentation should note that fact, currently it appears as if a function call like 

$i = fseek($filehandle, -100); 

would be adequate.

Reproduce code:
---------------
http://php.net/fseek

Expected result:
----------------
To move to a position before the end-of-file, you need to pass a negative value in offset and set the whence parameter to SEEK_END. 

Actual result:
--------------
To move to a position before the end-of-file, you need to pass a negative value in offset . 

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-09-04 07:28 UTC] svn@php.net
Automatic comment from SVN on behalf of torben
Revision: http://svn.php.net/viewvc/?view=revision&revision=288029
Log: Note that in order to use a negative offset to count from the end of
the file, you must specify SEEK_END in the 'whence' parameter.
Addresses bug #47371.
 [2009-09-04 07:29 UTC] torben@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.


 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Wed Jun 17 01:00:01 2026 UTC