linkinfo()

linkinfo() — Gets information about a 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.

What it does

This function is used to verify if a link (pointed to by path) really exists (using the same method as the S_ISLNK macro defined in stat.h).

Signature

linkinfo(string $path): int|false

Parameters

ParameterTypeWhat it takes
$pathstringPath to the link.

Return value

linkinfo() returns the st_dev field of the Unix C stat structure returned by the lstat system call. Returns a non-negative integer on success, -1 in case the link was not found, or false if an open.base_dir violation occurs.

Example

A runnable snippet:

echo linkinfo('/vmlinuz'); // 835

See also

symlink(), link(), readlink()

All PHP 8.5 built-in functions

Reference card built from the PHP manual page linkinfo() (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.