Bug #18006 Updated: more info
| From: | ilia at prohost dot org | Date: | Thu, 27 Jun 2002 01:08:27 +0000 |
| Subject: | Bug #18006 Updated: more info | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-12189@lists.php.net to get a copy of this message | ||
ID: 18006
Updated by: ilia@prohost.org
-Summary: php cannot overwrite exsiting data in file
Reported By: ilia@prohost.org
Status: Open
Bug Type: Scripting Engine problem
-Operating System: Linux 2.4.18
+Operating System: Linux
PHP Version: 4.2.1
New Comment:
Sorry, the 2nd example is wrong, here is the correct one.
<?php
$fp = fopen('a', 'a+');
$s=ftell($fp);
fseek($fp, $s+100, SEEK_SET);
fseek($fp, $s, SEEK_SET);
fwrite($fp, str_repeat('1', 100));
fclose($fp);
?>
Previous Comments:
------------------------------------------------------------------------
[2002-06-26 21:06:47] ilia@prohost.org
When doing the following in php, the result is a file that is 200
bytes, 100 bytes of NULL and 100 bytes of the actual data.
<?php
$fp = fopen('a', 'a+');
$s=ftell($fp);
ftruncate($fp, $s+100);
fwrite($fp, str_repeat('1', 100));
fclose($fp);
?>
In reality there should be a 100 byte file, full of 1s.
However, this example works
<?php
$fp = fopen('a', 'a+');
$s=ftell($fp);
ftruncate($fp, $s+100, SEEK_SET);
fseek($fp, $s, SEEK_SET);
fwrite($fp, str_repeat('1', 100));
fclose($fp);
?>
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=18006&edit=1