PHP: Hypertext Preprocessor (original) (raw)
lstat
(PHP 4, PHP 5, PHP 7, PHP 8)
lstat — Gives information about a file or symbolic link
Description
Parameters
filename
Path to a file or a symbolic link.
Return Values
See the manual page for stat() for information on the structure of the array that lstat() returns. This function is identical to the stat() function except that if the filename
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.
On failure, [false](reserved.constants.php#constant.false)
is returned.
Errors/Exceptions
Upon failure, an [E_WARNING](errorfunc.constants.php#constant.e-warning)
is emitted.
Examples
Example #1 Comparison of stat() and lstat()
<?php symlink('uploads.php', 'uploads');// Contrast information for uploads.php and uploads array_diff(stat('uploads'), lstat('uploads')); ?>
The above example will output something similar to:
Information that differs between the two files.
Array ( [ino] => 97236376 [mode] => 33188 [size] => 34 [atime] => 1223580003 [mtime] => 1223581848 [ctime] => 1223581848 [blocks] => 8 )
Notes
Note: The results of this function are cached. See clearstatcache() for more details.
See Also
- stat() - Gives information about a file
Found A Problem?
4 years ago
`Just for information and in reply to a previous message left 4 years ago by "salsi at icosaedro dot it" :
Files larger than 2 GiB can be handled on 64-bit Linux systems.
My test in a terminal is as follow (using tags to colour the results for ease of reading) :
$ php -v
$ date ; dd if=/dev/zero of=/tmp/php_test_huge bs=1024K count=2100 ; date ; ls -l /tmp/php_test_huge
$ php -r 'var_dump(lstat("/tmp/php_test_huge"));'
int(2050) [1]=> int(19923027) [2]=> int(33188) [3]=> int(1) [4]=> int(1000) [5]=> int(1000) [6]=> int(0) [7]=> int(2202009600) [8]=> int(1605079647) [9]=> int(1605080149) [10]=> int(1605080149) [11]=> int(4096) [12]=> int(4300808) ["dev"]=> int(2050) ["ino"]=> int(19923027) ["mode"]=> int(33188) ["nlink"]=> int(1) ["uid"]=> int(1000) ["gid"]=> int(1000) ["rdev"]=> int(0) ["size"]=> int(2202009600) ["atime"]=> int(1605079647) ["mtime"]=> int(1605080149) ["ctime"]=> int(1605080149) ["blksize"]=> int(4096) ["blocks"]=> int(4300808) } " ;?>`
9 years ago
`This function fails and returns FALSE with files larger than 2 GB on Linux 32-bits (PHP 7.1.0-dev):
$ dd if=/dev/zero of=/tmp/huge bs=1048576 count=2050
$ php -r 'var_dump(lstat("/tmp/huge"));'
--> Warning: lstat(): Lstat failed for /tmp/huge in Command line code on line 1
Window not tested. PHP 64-bits not tested.
`