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