|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2004-03-11 15:33 UTC] wez@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Nov 20 13:00:01 2025 UTC |
Description: ------------ ftell() reports the size of bytes added to a file instead of the position of the file pointer in the file. I guess this behavior is reproduceable only on appending data to a file, since on new files the file pointer position is at the same place of the number of bytes added. Reproduce code: --------------- <?php # Adding something to the test-file to see the behavior $fp = fopen("test", w); fwrite($fp, "Ciao"); fflush($fp); fclose($fp); # test-file saved and closed # Opening a file with non-zero size (just added some bytes) $fp = fopen("test", a); fwrite($fp, "Ciao"); fflush($fp); $s = filesize("test"); $t = ftell($fp); print("The pointer should be at the position $s, but ftell reports $t"); fclose($fp); ?> Expected result: ---------------- The pointer should be at the position 8, but ftell reports 8 Actual result: -------------- The pointer should be at the position 8, but ftell reports 4