PHP realpath() function

Definition and Usage

The realpath() function returns the absolute path.

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

If it fails, it returns false. 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 only 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