• « lchown
  • linkinfo »
  • PHP Manual
  • Функції Файлової Системи
  • Create a hard link

link

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

link — Create a hard link

Опис

link(string $target, string $link): bool

link() creates a hard link.

Параметри

target

Target of the link.

link

The link name.

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

Повертає true у разі успіху або false в разі помилки.

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

The function fails, and issues E_WARNING, if link already exists, or if target does not exist.

Приклади

Приклад #1 Creating a simple hard link

<?php
$target
= 'source.ext'; // This is the file that already exists
$link = 'newfile.ext'; // This the filename that you want to link it to

link($target, $link);
?>

Примітки

Зауваження: Ця функція незастосовна для роботи з віддаленими файлами, оскільки файл повинен бути доступним через файлову систему сервера.

Зауваження: For Windows only: This function requires PHP to run in an elevated mode or with the UAC disabled.

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

  • symlink() - Creates a symbolic link
  • readlink() - Returns the target of a symbolic link
  • linkinfo() - Gets information about a link
  • unlink() - Deletes a file