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
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: 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

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: Sat Sep 07 23:01:27 2024 UTC