lstat() function in PHP


The lstat() function returns information about a file or symbolic link. This function is similar to stat(), except that if the file parameter is a symbolic link, the status of the symlink is returned.

The function returns an array with the below given elements −

  • [0] or [dev] - Device number
  • [1] or [ino] - Inode number
  • [2] or [mode] - Inode protection mode
  • [3] or [nlink] - Number of links
  • [4] or [uid] - User ID of owner
  • [5] or [gid] - Group ID of owner
  • [6] or [rdev] - Inode device type
  • [7] or [size] - Size in bytes
  • [8] or [atime] - Last access time as Unix timestamp
  • [9] or [mtime] - Last modified time as Unix timestamp
  • [10] or [ctime] - Last inode change time as Unix timestamp
  • [11] or [blksize] - Blocksize of filesystem IO
  • [12] or [blocks] - Number of blocks allocated

Syntax

lstat(file_path)

Parameters

  • file_path − The path of the file to check.

Return

The lstat() function returns the elements shown above.

Example

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

Output

Array
(
[0] => 0
[1] => 0
[2] => 33206
[3] => 1
[4] => 0
[5] => 0
[6] => 0
[7] => 120
[8] => 17128173529
[9] => 1984185875
[10] => 1294322653
[11] => -1
[12] => -1
[dev] => 0
[ino] => 0
[mode] => 33206
[nlink] => 1
[uid] => 0
[gid] => 0
[rdev] => 0
[size] => 120
[atime] => 1718173529
[mtime] => 1984185875
[ctime] => 1294322653
[blksize] => -1
[blocks] => -1
)

Updated on: 24-Jun-2020

29 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements