Edit report at https://bugs.php.net/bug.php?id=61121&edit=1
ID: 61121 Updated by: [email protected] Reported by: gaoqiangscut at gmail dot com Summary: get error result -Status: Open +Status: Not a bug Type: Bug Package: POSIX related Operating System: ubuntu PHP Version: Irrelevant Block user comment: N Private report: N New Comment: PHP has a stat cache for performance reasons. Add this line before your second stat() call and you will get your expected output: clearstatcache(false,'a.txt'); If you read http://php.net/stat you will see it says: "Note: The results of this function are cached. See clearstatcache() for more details." Previous Comments: ------------------------------------------------------------------------ [2012-02-17 11:07:29] gaoqiangscut at gmail dot com Description: ------------ This is a bug in "stat" function, and I'm not quite sure which class this function belongs to. Detailed message for the OS and php version following: OS message: gao->:~$uname -a Linux gaoqiang-VirtualBox 2.6.38-8-generic #42-Ubuntu SMP Mon Apr 11 03:31:50 UTC 2011 i686 i686 i386 GNU/Linux php version: gao->:~$php -v PHP 5.3.5-1ubuntu7.4 with Suhosin-Patch (cli) (built: Dec 13 2011 18:25:14) Copyright (c) 1997-2009 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies Test script: --------------- <?php $file="a.txt"; $fp=fopen($file,"a"); $st=stat($file); echo "size= "; echo $st["size"]; echo "\n"; fputs($fp,"test\n"); fclose($fp); $st=stat($file); echo "size= "; echo $st["size"]; echo "\n"; ?> Expected result: ---------------- size=0 size=5 Actual result: -------------- size=0 size=0 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=61121&edit=1
