ID:               41763
 Updated by:       [EMAIL PROTECTED]
 Reported By:      kraghuba at in dot ibm dot com
-Status:           Open
+Status:           Bogus
 Bug Type:         Documentation problem
 Operating System: linux, windows
 PHP Version:      Irrelevant
 New Comment:

fopen(, "a") works as described but ftell() tells offset since
opening:
<?php
echo filesize("x") . " ";
$fp = fopen("x", "a");
echo ftell($fp) . " ";
fwrite($fp, "a");
echo ftell($fp);
?>
outputs e.g. 5 0 1.


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

[2007-06-21 12:54:29] kraghuba at in dot ibm dot com

Description:
------------
The current documentation of fopen for append mode doesn't state
clearly where the file pointer is set initally. The doc says :
"In a mode : Open for writing only; place the file pointer at the end
of the file. If the file does not exist, attempt to create it.".

But in reality the file pointer is set to 0, the file position is moved
to end of file before any write operation.

Please modify the document to make this clear. 

I also noticed that in response to following defect this was explained
: "Bug #15528: ftell does not work consistently"


Reproduce code:
---------------
<?php
$fp = fopen(__FILE__, "a"); 
var_dump($fp);
var_dump( ftell($fp) );   // ftell should return the size of the file 
fclose($fp);
?>


Expected result:
----------------
C:\workdir\test>php fopen.php
resource(5) of type (stream)
int(0)

Actual result:
--------------
C:\workdir\test>php fopen.php
resource(5) of type (stream)
int(0)


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


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

Reply via email to