• « is_file
  • is_readable »
  • PHP Manual
  • Функції Файлової Системи
  • Tells whether the filename is a symbolic link

is_link

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

is_link — Tells whether the filename is a symbolic link

Опис

is_link(string $filename): bool

Tells whether the given file is a symbolic link.

Параметри

filename

Path to the file.

Значення, що повертаються

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

Помилки/виключення

Під час збоїв буде видаватись E_WARNING.

Приклади

Приклад #1 Create and confirm if a file is a symbolic link

<?php
$link
= 'uploads';

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

Примітки

Зауваження: Рузультати цієї функції кешуються. Докладніше: clearstatcache().

Підказка

Починаючи з PHP 5.0.0, ця функція також може бути використана з деякими URL-обгортками. На сторінці Підтримувані протоколи та обгортки вказано, які обгортки підтримують сімейство функцій stat().

Прогляньте також

  • is_dir() - Tells whether the filename is a directory
  • is_file() - Tells whether the filename is a regular file
  • readlink() - Returns the target of a symbolic link