readlink()

readlink() — Returns the target of a symbolic link.

Built-in function of PHP 8.5. The manual lists it as available in PHP 4, PHP 5, PHP 7, PHP 8. This page is the reference card: signature, parameters and return value, plus the changelog and the example the manual provides.

Signature

readlink(string $path): string|false

Parameters

ParameterTypeWhat it takes
$pathstringThe symbolic link path.

Return value

Returns the contents of the symbolic link path or false on error. Note: The function fails if path is not a symlink, except on Windows, where the normalized path will be returned. The function fails if path is not a symlink, except on Windows, where the normalized path will be returned.

Example

A runnable snippet:

// output e.g. /boot/vmlinux-2.4.20-xfs echo readlink('/vmlinuz');

See also

is_link(), symlink(), linkinfo()

All PHP 8.5 built-in functions

Reference card built from the PHP manual page readlink() (PHP documentation, CC BY 3.0). The page is generated from the manual, so the wording of the parameter and return value text follows php.net.