link

(PHP 3, PHP 4, PHP 5)

link -- Создаёт жёсткую ссылку

Описание

bool link ( string target, string link )

link() создаёт жесткую ссылку. Возвращает TRUE в случае успешного завершения или FALSE в случае возникновения ошибки.

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

Замечание: Для Windows-платформ эта функция не реализована.

См. также описание функции symlink() для создания мягких ссылок, а также readlink() и linkinfo().



link
Guilherme Garnier
25-Apr-2006 11:32
I noticed that, differently from Unix ln command, the second parameter can´t be a directory name, i.e., if you want to create a link with the same filename of the target file (obviously on different directories), you must specify the filename on the link parameter.

Example:
Unix ln command:
ln /dir1/file /dir2/  // ok, creates /dir2/file link

PHP link function:
link ("/dir1/file", "/dir2/");  // wrong, gives a "File exists" warning
link ("/dir1/file", "/dir2/file");  // ok, creates /dir2/file link
mmap at upt dot org
15-May-2004 04:28
I think kop is confused regarding the semantics of link's argument order.  The user's comment states that target should not already exist, suggesting that it is the target that is being created.  As with the UNIX hardlink, ln(1), the target is the existing file.  I think kop meant to say php's link() will return an error if the second parameter, the link being created, already exists.

Also, as with the UNIX system call link will fail if the link being created exists on a different filesystem.
kop at meme dot com
25-Sep-2003 02:20
Note that link() will not work if the target already exists, at least as of php 4.1.2.

<is_writeablelinkinfo>
 Last updated: Mon, 14 Nov 2005