symlink() is a built-in function in PHP that is used to create a symbolic link for a target that already exists.
symlink(string $target, string $link): bool
target: The target file for which the symbolic link needs to be created.
link: The name of the symbolic link.
symlink() returns True upon success and False upon failure.
In the following code, we create a symbolic link for the temp.txt file and name it temporary.
After creating the symbolic link, we use the readlink() function, which returns the target of the symbolic link to verify that temporary points to the temp.txt file as intended.
<?php$target = 'temp.txt';$link = 'temporary';symlink($target, $link);print_r(readlink($link));?>
Free Resources