realpath
Function • Params and return types changed in PHP 8.0
Returns canonicalized absolute pathname.
realpath Function synopsis
realpath(string $path): string|false
Parameters
$path
Typestring
The path being checked.
Return value
Typestring|false
Returns the canonicalized absolute pathname on success. The resulting path
will have no symbolic link, /./ or /../ components. Trailing delimiters,
such as \ and /, are also removed.
realpath returns false on failure, e.g. if
the file does not exist.
The running script must have executable permissions on all directories in
the hierarchy, otherwise [`realpath`](/codex/realpath) will return
`false`.
For case-insensitive filesystems [`realpath`](/codex/realpath) may or may
not normalize the character case.
The function [`realpath`](/codex/realpath) will not work for a file which
is inside a Phar as such path would be a virtual path, not a real one.
On Windows, junctions and symbolic links to directories are only expanded by
one level. Changes to the realpath Function
PHP 8.0
- Return type added:
string|false - Parameter type added for parameter #1 (
$path):string
- realpath($path)
+ realpath(string $path): string|false realpath Function Availability
realpath Function Availability| PHP Version | Availability |
|---|---|
| PHP 8.6Upcoming Release | Yes |
| PHP 8.5Supported (Latest) | Yes |
| PHP 8.4Supported | Yes |
| PHP 8.3Security-Fixes Only | Yes |
| PHP 8.2Security-Fixes Only | Yes |
| PHP 8.1Unsupported | Yes |
| PHP 8.0Unsupported | Yes |
| PHP 7.4Unsupported | Yes |
| PHP 7.3Unsupported | Yes |
| PHP 7.2Unsupported | Yes |
| PHP 7.1Unsupported | Yes |
| PHP 7.0Unsupported | Yes |
| PHP 5.6Unsupported | Yes |
| PHP 5.5Unsupported | Yes |
| PHP 5.4Unsupported | Yes |
| PHP 5.3Unsupported | Yes |