PHP stat () function
Definition and Usage
stat () function returns information about the file.
This function returns an array containing the following elements:
- [0] or [dev] - device number
- [1] or [ino] - inode number
- [2] or [mode] - inode protection mode
- [3] or [nlink] - the number of connections
- [4] or [uid] - owner user ID
- [5] or [gid] - owner group ID
- [6] or [rdev] - inode device type
- [7] or [size] - Number of bytes of the file size
- [8] or [atime] - time of last access (Unix timestamp)
- [9] or [mtime] - last modified (Unix timestamp)
- [10] or [ctime] - Last inode change time (Unix timestamp)
- [11] or [blksize] - IO file system block size (if supported)
- [12] or [blocks] - The number of occupied blocks
grammar
stat(filename)
参数 | 描述 |
---|---|
filename | 必需。规定文件的路径。 |
Tips and Notes
Note: The results from the server to the result returned by this function is not the same server.This array contains a numerical index, including the name index, or both.
Note: The results of this function are cached.Use clearstatcache () to clear the cache.
Examples
<?php
$stat = stat('test.txt');
echo 'Acces time: ' .$stat['atime'];
echo '<br />Modification time: ' .$stat['mtime'];
echo '<br />Device number: ' .$stat['dev'];
?>
$stat = stat('test.txt');
echo 'Acces time: ' .$stat['atime'];
echo '<br />Modification time: ' .$stat['mtime'];
echo '<br />Device number: ' .$stat['dev'];
?>
The code above will output:
Access time: 1141633430
Modification time: 1141298003
Device number: 0
Modification time: 1141298003
Device number: 0
Complete PHP Filesystem Reference Manual