ID:               46023
 Updated by:       [EMAIL PROTECTED]
 Reported By:      richard dot kuchar at gmail dot com
-Status:           Open
+Status:           Feedback
 Bug Type:         Filesystem function related
 Operating System: Debian (etch)
 PHP Version:      5.2CVS-2008-09-08 (snap)
 New Comment:

I can not reproduce this with current CVS checkout of PHP_5_2 branch
and using CLI. How do you run the script?


Previous Comments:
------------------------------------------------------------------------

[2008-09-09 09:11:31] richard dot kuchar at gmail dot com

Yes, I delete file before running script every time

------------------------------------------------------------------------

[2008-09-08 23:45:38] [EMAIL PROTECTED]

Do you have deleted the file before running again?

------------------------------------------------------------------------

[2008-09-08 14:01:15] richard dot kuchar at gmail dot com

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


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=46023&edit=1

Reply via email to