What is the is_link() function in PHP?

The is_link() function in PHP checks whether the given filename is a symbolic linkA symbolic link serves as a reference to a file or directory as either a relative or absolute path..

Syntax

is_link(string $name): bool

Parameters

name: This specifies the path to the file we want to check.

Return value

is_link() returns true if the provided filename exists and is also a symbolic link. Otherwise, it returns false.

Code

The following code shows how to use the is_link() function.

<?php
$name = "documents"; // a file path which is checked whether it is a symbolic link or not.
if(is_link(name))
{
echo ("name is a link"); // here if the argument is a valid symbolic link
}
else
{
echo ("name is not a link"); // here if the argument is not a valid symbolic link
}
?>

This function produces cache output. We have to clear the cache by using the clearstatcache() function.

Free Resources

Copyright ©2025 Educative, Inc. All rights reserved