Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

lstat(3) [php man page]

LSTAT(3)								 1								  LSTAT(3)

lstat - Gives information about a file or symbolic link

SYNOPSIS
array lstat (string $filename) DESCRIPTION
Gathers the statistics of the file or symbolic link named by $filename. PARAMETERS
o $filename - Path to a file or a symbolic link. RETURN VALUES
See the manual page for stat(3) for information on the structure of the array that lstat(3) returns. This function is identical to the stat(3) 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. EXAMPLES
Example #1 Comparison of stat(3) and lstat(3) <?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 ) ERRORS
/EXCEPTIONS Upon failure, an E_WARNING is emitted. NOTES
Note The results of this function are cached. See clearstatcache(3) for more details. Tip As of PHP 5.0.0, this function can also be used with some URL wrappers. Refer to "Supported Protocols and Wrappers" to determine which wrappers support stat(3) family of functionality. SEE ALSO
stat(3). PHP Documentation Group LSTAT(3)

Check Out this Related Man Page

STAT(3) 								 1								   STAT(3)

stat - Gives information about a file

SYNOPSIS
array stat (string $filename) DESCRIPTION
Gathers the statistics of the file named by $filename. If $filename is a symbolic link, statistics are from the file itself, not the sym- link. lstat(3) is identical to stat(3) except it would instead be based off the symlinks status. PARAMETERS
o $filename - Path to the file. RETURN VALUES
stat(3) and fstat(3) result format +--------+--------------------------------------+---+ |Numeric | | | | | | | | | Associative | | | | | | | | Description | | | | | | +--------+--------------------------------------+---+ | 0 | | | | | | | | | dev | | | | | | | | device number | | | | | | | 1 | | | | | | | | | ino | | | | | | | | inode number * | | | | | | | 2 | | | | | | | | | mode | | | | | | | | inode protection mode | | | | | | | 3 | | | | | | | | | nlink | | | | | | | | number of links | | | | | | | 4 | | | | | | | | | uid | | | | | | | | userid of owner * | | | | | | | 5 | | | | | | | | | gid | | | | | | | | groupid of owner * | | | | | | | 6 | | | | | | | | | rdev | | | | | | | | device type, if inode device | | | | | | | 7 | | | | | | | | | size | | | | | | | | size in bytes | | | | | | | 8 | | | | | | | | | atime | | | | | | | | time of last access (Unix timestamp) | | | | | | | 9 | | | | | | | | | mtime | | | | | | | | time of last modification (Unix | | | | timestamp) | | | | | | | 10 | | | | | | | | | ctime | | | | | | | | time of last inode change (Unix | | | | timestamp) | | | | | | | 11 | | | | | | | | | blksize | | | | | | | | blocksize of filesystem IO ** | | | | | | | 12 | | | | | | | | | blocks | | | | | | | | number of 512-byte blocks allocated | | | | ** | | | | | | +--------+--------------------------------------+---+ * On Windows this will always be 0. ** Only valid on systems supporting the st_blksize type - other systems (e.g. Windows) return -1. In case of error, stat(3) returns FALSE. Note Because PHP's integer type is signed and many platforms use 32bit integers, some filesystem functions may return unexpected results for files which are larger than 2GB. ERRORS
/EXCEPTIONS Upon failure, an E_WARNING is emitted. EXAMPLES
Example #1 stat(3) example <?php /* Get file stat */ $stat = stat('C:phpphp.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(3) information together with touch(3) <?php /* Get file stat */ $stat = stat('C:phpphp.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...'; } } ?> NOTES
Note Note that time resolution may differ from one file system to another. Note The results of this function are cached. See clearstatcache(3) for more details. Tip As of PHP 5.0.0, this function can also be used with some URL wrappers. Refer to "Supported Protocols and Wrappers" to determine which wrappers support stat(3) family of functionality. SEE ALSO
lstat(3), fstat(3), filemtime(3), filegroup(3). PHP Documentation Group STAT(3)
Man Page