#38621 [Opn->Bgs]: failed to truncate file using fopen in "w" mode

From: Date: Mon, 28 Aug 2006 09:51:59 +0000
Subject: #38621 [Opn->Bgs]: failed to truncate file using fopen in "w" mode
References: 1  Groups: php.doc 
Request: Send a blank email to phpdoc+get-969373845@lists.php.net to get a copy of this message
ID: 38621 Updated by: bjori@php.net Reported By: rrlin923 at hotmail dot com -Status: Open +Status: Bogus Bug Type: Documentation problem Operating System: Linux PHP Version: 5.1.5 -Assigned To: +Assigned To: bjori 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 clearstatcache(); Previous Comments: ------------------------------------------------------------------------ [2006-08-28 06:58:52] tony2001@php.net The documentation is apparently wrong. ------------------------------------------------------------------------ [2006-08-28 03:16:30] rrlin923 at hotmail dot com Description: ------------ The manual said that "w" mode for fopen() will place the file pointer at the beginning of the file and truncate the file to zero length. But the file cannot be truncated using that "w" mode by fopen(). Reproduce code: --------------- <? $file = "t.log"; $add_content = "add this"; /* prepare the file to be truncated */ $fh = fopen($file, 'w'); $res = fwrite($fh, $add_content) or die("write file error"); fclose($fh); echo $file . " size : " . filesize($file) . "bytes. \n"; $sh = fopen($file, 'w'); fclose($sh); echo $file . " size : " . filesize($file) . "bytes. \n"; ?> Expected result: ---------------- t.log size : 8bytes. t.log size : 0bytes. Actual result: -------------- t.log size : 8bytes. t.log size : 8bytes. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=38621&edit=1

« previous php.doc (#969373845) next »