php8.5
Home/ Manual/ filesystem / functions/ is_link

is_link

PHP function Edit on GitHub ✎

(PHP 4, PHP 5, PHP 7, PHP 8)

Tells whether the filename is a symbolic link

Description

is_link(string $filename): bool

Tells whether the given file is a symbolic link.

Parameters

filename

Path to the file.

Return Values

Returns true if the filename exists and is a symbolic link, false otherwise.

Errors/Exceptions Failure

Examples

Create and confirm if a file is a symbolic link

php
<?php
$link = 'uploads';

if (is_link($link)) {
    echo readlink($link);
} else {
    symlink('uploads.php', $link);
}
?>

Notes Clearstatcache Stat

See Also

Source: reference/filesystem/functions/is-link.xml · from the official PHP manual (php/doc-en)