PHP realpath() Function

Definition and Usage

The realpath() function returns the absolute path.

The function deletes all symbolic links (such as '/./', '/../' and redundant '/'), and returns the absolute path name.

Returns false if it fails. For example, if the file does not exist.

Syntax

readlink(linkpath)
Parameter Description
linkpath Required. Specifies the connection path to be checked.

Description

On BSD systems, if it is just linkpath If it does not exist, PHP will not return false like other systems.

Example

<?php
echo realpath("test.txt");
?>

Output:

C:\Inetpub\testweb\test.txt