Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

php

What is the lstat() function in PHP?

Muhammad Ashir

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Answers Code

In PHP, the lstat() function is used to return information about a file or a symbolic link. It provides statistics about the particular file provided in the argument.

Syntax

lstat(string $filename): array|false

Parameters

  • filename: The path to the file or symbolic link as a string.

Return value

lstat() returns an array that includes information on the following elements upon success. It returns false on failure.

Note: This function is similar to stat(), except that if the file parameter is a symbolic link, the status of the symlink is returned instead of the status of the file pointed to by the symlink.

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

Code

The code below shows the usage of lstat(). It also compares the results of lstat() to stat().

main.php
test.php
<?php
symlink('test.php', 'test');
print_r("\n*****stat*****\n");
print_r(stat('test'));
print_r("\n*****lstat*****\n");
print_r(lstat('test'));
?>

RELATED TAGS

php

CONTRIBUTOR

Muhammad Ashir
Copyright ©2022 Educative, Inc. All rights reserved

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Answers Code
Keep Exploring