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
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: ccjeagle at ms6 dot hinet dot net
New email:
PHP Version: OS:

 

 [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-2022 The PHP Group
All rights reserved.
Last updated: Fri Dec 09 18:05:54 2022 UTC