Example 1 — Read Where a Link Points
Create a symbolic link and read the path stored in it.
<?php
$link = __DIR__ . '/current';
@unlink($link);
symlink('target.txt', $link);
echo "Link points to: ", readlink($link), PHP_EOL; How It Works
- unlink() removes an old link so the script can run again.
- symlink() creates current as a link that points to target. txt.
- readlink() reads the stored path from the link.
- The path is printed exactly as it was saved.

