php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #5859 fseek() with whence SEEK_CUR wrong
Submitted: 2000-07-30 12:14 UTC Modified: 2000-07-30 12:21 UTC
From: ccjeagle at ms6 dot hinet dot net Assigned:
Status: Closed Package: Other
PHP Version: 4.0.1pl2 OS: FreeBSD-4.1RC
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
15 - 6 = ?
Subscribe to this entry?

 
 [2000-07-30 12:14 UTC] ccjeagle at ms6 dot hinet dot net
// Begin of my.txt
1234567890
// End of my.txt

With the script :
// Begin of test.php
<?
$fp = fopen("my.txt","r") ;
echo fseek($fp,3) ; echo fgetc($fp) ;
echo fseek($fp,0,SEEK_CUR) ; echo fgetc($fp) ;
fclose($fp) ;
?>
// End of test

The result would be '0405', which should be 
wrong with offset 0 with SEEK_CUR.

Gegards

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-07-30 12:21 UTC] derick@php.net
I think it is correct. The fgetc gets a character from file and advances the filepointer, si that the next time you do a fgetc you'll get the next chracter. After the first fgetc the filepointer is already on position 4 ('5') and so fseek ($fp, 0, SEEK_CUR) ideed does nothing.

Closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 14:01:28 2024 UTC