Bug #77081 [NEW]: fopen() c mode positions file pointer at the end

From: Date: Mon, 29 Oct 2018 15:21:46 +0000
Subject: Bug #77081 [NEW]: fopen() c mode positions file pointer at the end
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-217739@lists.php.net to get a copy of this message
From: cmb Operating system: Windows PHP version: 7.3Git-2018-10-29 (Git) Package: Filesystem function related Bug Type: Bug Bug description:fopen() c mode positions file pointer at the end Description: ------------ The documentation of fopen() mode c[1] states: | The file pointer is positioned on the beginning of the file. However, this does not happen with PHP 7.3 on Windows; instead the file pointer is positioned at the end of the file, even though ftell() claims otherwise. It works as expected on Linux and with PHP 7.2 on Windows. [1] <http://php.net/manual/en/function.fopen.php> Test script: --------------- <?php $filename = __DIR__ . '/fopen-c.txt'; file_put_contents($filename, 'foo'); $stream = fopen($filename, 'c'); ftruncate($stream, 0); // fseek($stream, 0); var_dump(ftell($stream)); fwrite($stream, 'bar'); fclose($stream); var_dump(file_get_contents($filename)); Expected result: ---------------- int(0) string(3) "bar" Actual result: -------------- int(0) string(6) " bar" -- Edit bug report at https://bugs.php.net/bug.php?id=77081&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=77081&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=77081&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=77081&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=77081&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=77081&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=77081&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=77081&r=needscript Try newer version: https://bugs.php.net/fix.php?id=77081&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=77081&r=support Expected behavior: https://bugs.php.net/fix.php?id=77081&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=77081&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=77081&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=77081&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=77081&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=77081&r=dst IIS Stability: https://bugs.php.net/fix.php?id=77081&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=77081&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=77081&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=77081&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=77081&r=mysqlcfg

« previous php.bugs (#217739) next »