(PHP 4, PHP 5, PHP 7)
stat — �����ļ�����Ϣ
$filename
) : array
��ȡ�� filename
ָ�����ļ���ͳ����Ϣ�����
filename
�Ƿ������ӣ���ͳ����Ϣ�ǹ��ڱ������ļ�����ģ������Ƿ������ӡ�
lstat() �� stat() ��ͬ��ֻ�������᷵�ط������ӵ�״̬��
filename
�ļ���·����
�����±� | ������������ PHP 4.0.6�� | ˵�� |
---|---|---|
0 | dev | device number - �豸�� |
1 | ino | inode number - inode ���� |
2 | mode | inode protection mode - inode ����ģʽ |
3 | nlink | number of links - ��������Ŀ |
4 | uid | userid of owner - �����ߵ��û� id |
5 | gid | groupid of owner- �����ߵ��� id |
6 | rdev | device type, if inode device * - �豸���ͣ������ inode �豸�Ļ� |
7 | size | size in bytes - �ļ���С���ֽ��� |
8 | atime | time of last access (unix timestamp) - �ϴη���ʱ�䣨Unix ʱ����� |
9 | mtime | time of last modification (unix timestamp) - �ϴ���ʱ�䣨Unix ʱ����� |
10 | ctime | time of last change (unix timestamp) - �ϴθı�ʱ�䣨Unix ʱ����� |
11 | blksize | blocksize of filesystem IO * - �ļ�ϵͳ IO �Ŀ��С |
12 | blocks | number of blocks allocated - ��ռ�ݿ����Ŀ |
* - ����֧�� st_blksize ���͵�ϵͳ����Ч������ϵͳ���� Windows������ -1��
�������stat() ���� FALSE
��
Note: ��Ϊ PHP �������������з������Ͷ��Һܶ�ƽ̨ʹ�� 32 λ���ͣ��� 2GB ���ϵ��ļ���һЩ�ļ�ϵͳ�������ܷ�����Ԥ�ڵĽ�� ��
����ʱ����� E_WARNING
����Ĵ���
�汾 | ˵�� |
---|---|
4.0.6 | ����һ������������ļ���ͳ����Ϣ����������������г��ĵ�Ԫ�������±���㿪ʼ��������������֮���Ի�����ͨ���������������ʡ� |
Example #1 stat() ����
<?php
/* Get file stat */
$stat = stat('C:\php\php.exe');
/*
* Print file access time, this is the same
* as calling fileatime()
*/
echo 'Access time: ' . $stat['atime'];
/*
* Print file modification time, this is the
* same as calling filemtime()
*/
echo 'Modification time: ' . $stat['mtime'];
/* Print the device number */
echo 'Device number: ' . $stat['dev'];
?>
Example #2 Using stat() information together with touch()
<?php
/* Get file stat */
$stat = stat('C:\php\php.exe');
/* Did we failed to get stat information? */
if (!$stat) {
echo 'stat() call failed...';
} else {
/*
* We want the access time to be 1 week
* after the current access time.
*/
$atime = $stat['atime'] + 604800;
/* Touch the file */
if (!touch('some_file.txt', time(), $atime)) {
echo 'Failed to touch file...';
} else {
echo 'touch() returned success...';
}
}
?>
Note:
ע�⣺��ͬ�ļ�ϵͳ��ʱ����жϷ��������Dz���ͬ�ġ�
Note: �˺����Ľ���ᱻ���档�μ� clearstatcache() �Ի�ø���ϸ�ڡ�
�� PHP 5.0.0 ��, �˺���Ҳ����ijЩ URL ��װ������μ� ֧�ֵ�Э��ͷ�װЭ���Ի��֧�� stat() ϵ�к������ܵİ�װ���б�