PHP realpath() Function

The realpath() function returns the absolute pathname.This function removes all symbolic links (like '/./', '/../' and extra '/') and returns the absolute pathname.This function returns FALSE on failure.

string realpath ( string $path )

realpath() expands all symbolic links and resolves references to /./, /../ and extra / characters in the input path and returns the canonicalized absolute pathname.

Example -

The above example will output : -

/etc/passwd
/tmp

Example -

The above example will output : -

C:\WINDOWS\System32
C:\Program Files

ParameterDescription
pathThe path being checked.

Note -

Whilst a path must be supplied, the value can be blank or NULL In these cases, the value is interpreted as the current directory.