Bug #72930 [Opn->Nab]: filesize bug after rewrite.
| From: | cmb@php.net | Date: | Tue, 23 Aug 2016 10:53:32 +0000 |
| Subject: | Bug #72930 [Opn->Nab]: filesize bug after rewrite. | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-203508@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=72930&edit=1
ID: 72930
Updated by: cmb@php.net
Reported by: frank123m at gmail dot com
Summary: filesize bug after rewrite.
-Status: Open
+Status: Not a bug
Type: Bug
Package: Math related
Operating System: ubuntu
PHP Version: 5.6.25
-Assigned To:
+Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
The bug is rather in your script. You're reading the file size,
and writing this (increased by one) back to the file. Then you
expect the file size to have increased.
Previous Comments:
------------------------------------------------------------------------
[2016-08-23 10:36:53] frank123m at gmail dot com
Description:
------------
function hit_count() {
$filename = 'count.txt';
$handle = fopen($filename, 'r');
$current = fread($handle, filesize($filename));
fclose($handle);
$current_inc = $current + 1;
$handle = fopen($filename, 'w');
fwrite($handle, $current_inc);
fclose($handle);
$handle = fopen($filename, 'r');
$current = fread($handle, filesize($filename));
fclose($handle);
echo $current;
}
Test script:
---------------
count.txt:
example: 99->100
echo $current will show 10 instead of 100.
filesize($filename) remain the same after fwrite. its the bug.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=72930&edit=1