|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2008-09-08 23:45 UTC] felipe@php.net
[2008-09-09 09:11 UTC] richard dot kuchar at gmail dot com
[2008-10-24 15:48 UTC] jani@php.net
[2008-11-01 01:00 UTC] php-bugs at lists dot php dot net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 01 00:00:01 2025 UTC |
Description: ------------ opening file in append mode and writing to file wrote data twice to file Reproduce code: --------------- <?php $filename = 'test.txt'; $somecontent = "Add this to the file\n"; // In our example we're opening $filename in append mode. // The file pointer is at the bottom of the file hence // that's where $somecontent will go when we fwrite() it. if (!$handle = fopen($filename, 'a')) { echo "Cannot open file ($filename)"; exit; } // Write $somecontent to our opened file. if (fwrite($handle, $somecontent) === FALSE) { echo "Cannot write to file ($filename)"; exit; } fclose($handle); ?> Expected result: ---------------- in 'test.txt': Add this to the file\n Actual result: -------------- in 'test.txt': Add this to the file\nAdd this to the file\n