The readlink() function returns the target of a symbolic link.
PHP readlink() Function has the following syntax.
readlink(linkpath)
Parameter | Is Required | Description |
---|---|---|
linkpath | Required. | Link path to check |
This function returns the target of the link on success, or FALSE on failure.
This function is not implemented on Windows platforms.
PHP readlink() function takes a link name and returns the target that the link points to.
<?php
$target = readlink("/home/andrew/myfile.txt");
print $target;
?>
The following code shows how to check if the filename is a symbolic link.
<?php
$link = 'images';
if (is_link($link)) {
echo(readlink($link));
} else {
symlink('uploads.php', $link);
}
?>