unlink() - the right approach
code snippet from my project to remove it only if it's a symbolic link
if(file_exists($linkfile)) {
if(is_link($linkfile)) {
unlink($linkfile);
} else {
exit("$linkfile exists but not symbolic link\n");
}
}
readlink (), returns the target of the link, you can run unlink on this
if(is_link($linkfile)) {
$target = readlink($linkfile)
unlink($target)
}
user557846
source
share