|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2018-10-10 14:58 UTC] miloslav dot hula at gmail dot com
Description: ------------ URL in a test script shows, how fseek() in 'a+' mode breaks contents reading. Documentation of fopen() says, that fseek() is OK, but documentation of fseek() says, that seeking in a+ mode is bad idea. In documentation of fopen(): a+ - Open for reading and writing; place the file pointer at the end of the file. If the file does not exist, attempt to create it. In this mode, fseek() only affects the reading position, writes are always appended. In documentation of fseek(): If you have opened the file in append (a or a+) mode, any data you write to the file will always be appended, regardless of the file position, and the result of calling fseek() will be undefined. Test script: --------------- https://3v4l.org/gTXsR PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Nov 05 06:00:01 2025 UTC |
The issue highlighted in the test script relates to the use of fseek() in 'a+' mode, which appears to disrupt content reading. This seems to stem from conflicting information in the documentation. While the fopen() documentation indicates that fseek() can be used in 'a+' mode to adjust the reading position (with writes always being appended), the fseek() documentation contradicts this by stating that using fseek() in append mode ('a' or 'a+') can lead to undefined behavior. This discrepancy suggests a need for clarification in the documentation to ensure proper usage and avoid potential issues in file handling