• « lchown
  • linkinfo »
  • PHP Manual
  • Filesystem Funcții
  • Create a hard link

link

(PHP 4, PHP 5, PHP 7)

link — Create a hard link

Descrierea

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

link() creates a hard link.

Parametri

target

Target of the link.

link

The link name.

Valorile întoarse

Întoarce valoarea true în cazul succesului sau false în cazul eșecului.

Erori/Excepții

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

Exemple

Example #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);
?>

Note

Notă: Această funcție nu va lucra cu fișiere la distanță, deoarece fișierul care trebuie să fie examinat trebuie să fie accesibil prin intermediul sistemului de fișiere al serverului.

Notă: For Windows only: This function requires PHP to run in an elevated mode or with the UAC disabled.

A se vedea și

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