dongshiliao7990
dongshiliao7990
2017-08-01 12:26
浏览 10
已采纳

filectime()没有改变(即使手动删除文件)

I have the following code:

<?php

function logAction($action,$file){

    /**
     * delete the file
     */

    if((time()-filectime(ROOT_PATH.'/logs/'.$file)) > LOG_CLEAN){

        unlink(ROOT_PATH.'/logs/'.$file);

    };

    /**
     * write the action
     */

    $f = fopen(ROOT_PATH.'/logs/'.$file,'a');

    $data = "[".date('d-m-Y H:i:s')."] ".$action."
";

    fwrite($f,$data);

    fclose($f);

    return true;

};

?>

The problem is: filectime() is not changing values. When I write it down, it stays the same, even if a new file is generated (for example if I delete the log file manually).

What's the problem with my code?

Thanks in advance.

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dongsi4547
    dongsi4547 2017-08-01 12:27
    已采纳

    The result filectime() function are cached. Use clearstatcache() to clear the cache. The clearstatcache() function clears the file status cache. check the documentation here php filectime() php clearstatcache()

    点赞 评论

相关推荐