PHP | lstat( )函数
PHP中的 lstat()函数用于返回有关文件或符号链接的信息。它收集作为参数发送给 lstat()函数的文件的统计信息。该函数返回一个数组,其中包含有关以下元素的信息:
- [0] 或 [dev] – 设备编号
- [1] 或 [ino] – Inode 编号
- [2] 或 [mode] – inode 保护模式
- [3] 或 [nlink] – 链接数
- [4] 或 [uid] – 所有者的用户 ID
- [5] 或 [gid] – 所有者的组 ID
- [6] 或 [rdev] – Inode 设备类型
- [7] 或 [size] – 大小(以字节为单位)
- [8] 或 [atime] – 上次访问(作为 Unix 时间戳)
- [9] 或 [mtime] – 最后修改时间(作为 Unix 时间戳)
- [10] 或 [ctime] – 最后一次 inode 更改(作为 Unix 时间戳)
- [11] 或 [blksize] – 文件系统 IO 的块大小(如果支持)
- [12] 或 [blocks] – 分配的块数
笔记:
This function is similar to stat(), except that if the file parameter is a symbolic link, the status of the symlink is return not the status of the file pointed to by the symlink.
句法:
lstat(file)
使用的参数:
PHP中的 lstat()函数接受一个参数。
- file :它是指定文件的强制参数。
返回值:
它返回一个包含上述元素的数组。
例外:
- lstat()函数的结果因服务器而异。
- 此函数的结果被缓存,因此 clearstatcache()函数用于清除缓存。
- 失败时发出 E_WARNING。
示例:1
Input : print_r(lstat("gfg.txt"));
Output :
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
)
示例:2
Input : symlink('gfg.php', 'gfg');
array_diff(stat('gfg'), lstat('gfg'));
Output :
Array
(
[ino] => 97236376
[mode] => 33188
[size] => 34
[atime] => 1223580003
[mtime] => 1223581848
[ctime] => 1223581848
[blocks] => 8
)
Explanation: Difference of the results of stat() and lstat() function
下面的程序说明了 lstat()函数。
程序 1
php
php
php
输出:
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
)
节目二
PHP
输出:
Array
(
[ino] => 97236376
[mode] => 33188
[size] => 34
[atime] => 1223580003
[mtime] => 1223581848
[ctime] => 1223581848
[blocks] => 8
)
方案 3
PHP
输出:
Array (
[0] => 2161
[1] => 18351063
[2] => 33188
[3] => 1
[4] => 1036
[5] => 1036
[6] => 0
[7] => 270081
[8] => 1382409024
[9] => 1382409631
[10] => 1382409631
[11] => 4096
[12] => 528
[dev] => 2161
[ino] => 18351063
[mode] => 33188
[nlink] => 1
[uid] => 1036
[gid] => 1036
[rdev] => 0
[size] => 270081
[atime] => 1382409024
[mtime] => 1382409631
[ctime] => 1382409631
[blksize] => 4096
[blocks] => 528 )
相关文章: PHP | stat()函数
参考:
http:// PHP.net/manual/en/函数.lstat。 PHP