当前位置: 首页 > 网络学院 > 服务端脚本教程 > PHP > stat() 函数
The stat() function returns information about a file.
stat()函数的作用是:返回一个文件的信息。
This function returns an array with the following elements:
这个函数将返回一个包含下列元素的数组:
stat(file) |
Parameter 参数 | Description 描述 |
---|---|
file | Required. Specifies the file to check 必要参数。指定文件对 |
Note: The results from this function will differ from server to server. The array may contain the number index, the name index, or both.
注意:从这个函数返回的结果与“服务器到服务器[server to server]”的结果是不相同的。这个数组包含了数字索引、名称索引或同时包含上述二者。
Note: The result of this function are cached. Use clearstatcache() to clear the cache.
注意:这个函数的结果将被自动缓存。你可以使用clearstatcache()函数来清除这个缓存。
Tip: This function is similar to fstat(), except that with this function the file does not have to be open.
提示:stat()函数与fstat()大致类似。唯一的不同点就是:stat() 函数返回的文件对象不需要事先打开。
<?php $file = fopen("test.txt","r"); print_r(stat($file)); fclose($file); ?> |
The output of the code above could be:
上述代码将输出下面的结果:
Array ( [0] => 0 [1] => 0 [2] => 33206 [3] => 1 [4] => 0 [5] => 0 [6] => 0 [7] => 92 [8] => 1141633430 [9] => 1141298003 [10] => 1138609592 [11] => -1 [12] => -1 [dev] => 0 [ino] => 0 [mode] => 33206 [nlink] => 1 [uid] => 0 [gid] => 0 [rdev] => 0 [size] => 92 [atime] => 1141633430 [mtime] => 1141298003 [ctime] => 1138609592 [blksize] => -1 [blocks] => -1 ) |