我怎么能得到最后一次在php中打开文件

How can I get the last time the file was opened in PHP?

Can anyone help me?

I just found the stat() function but this just returns time of last modification but I need last time the file was opened.

You can use the function fileatime().

The following example:

<?php
    $filename = "/Users/rafaelalmeida/projects/UFP-API/README.md";

    if (file_exists($filename)) {
        echo "$filename was last accessed: " . date("F d Y H:i:s.", fileatime($filename));
    }

The result from the code above is: /Users/rafaelalmeida/projects/UFP-API/README.md was last accessed: February 17 2017 00:29:20..

You can read more about fileatime() function here.