PHP lstat() Function

Definition and Usage

The lstat() function returns information about the file or symbolic link.

Syntax

lstat(file)
Parameter Description
file Required. Specifies the file to be checked.

Description

Get by file Statistics information of the file or symbolic link specified by the parameter.

Return format of lstat()

Numeric index Associated key name (since PHP 4.0.6) Description
0 dev Device name
1 ino Number
2 mode inode protection mode
3 nlink Number of hard links
4 uid User ID of the owner
5 gid Group ID of the owner
6 rdev Device type, if it is an inode device
7 size Number of bytes in file size
8 atime Last access time (Unix timestamp)
9 mtime Last modified time (Unix timestamp)
10 ctime Last change time (Unix timestamp)
11 blksize The block size of the file system IO
12 blocks The number of blocks occupied

Tips and Comments

Tip:This function is similar to stat() The function is the same, the only difference is that if file If the parameter is a symbolic link, the status of the symbolic link is returned, not the status of the file pointed to by the symbolic link.

Note:The result of this function will be cached. Please use clearstatcache() to clear the cache.

Example

<?php
print_r(lstat("test.txt"));
?>

Output similar to:

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
)