❮ PHP Filesystem Reference
Example
Returns the absolute pathname:
The output of the code above will be:
C:\Inetpub\testweb\test.txt
Definition and Usage
The realpath[] function returns the absolute pathname.
This function removes all symbolic links [like '/./', '/../' and extra '/'] and returns the absolute pathname.
Syntax
Parameter Values
path | Required. Specifies the path to check |
Technical Details
The absolute pathname on success, FALSE on failure |
4.0+ |
PHP 5.3: PHP 5.2.1: |
❮ PHP Filesystem Reference
A file path describes the location of a file in a web site's folder structure.
File Path Examples
The "picture.jpg" file is located in the same folder as the current page | |
The "picture.jpg" file is located in the images folder in the current folder | |
The "picture.jpg" file is located in the images folder at the root of the current web | |
The "picture.jpg" file is located in the folder one level up from the current folder |
HTML File Paths
A file path describes the location of a file in a web site's folder structure.
File paths are used when linking to external files, like:
- Web pages
- Images
- Style sheets
- JavaScripts
Absolute File Paths
An absolute file path is the full URL to a file:
Example
Try it Yourself »
The
Explanation:
In the above example, we are using the full URL address of the file.
Relative File Path:
A relative file path is the address of a file relative to the current page.
Example 1:
DOCTYPE html>
Relative File Path
Output:
Explanation:
In the above example, we are using relative file path when the required file is located in the images folder at the root of the current web.
Example 2:
DOCTYPE html>
Relative File Path
Output:
Explanation:
In the above example, we are using relative file path when the required file is located in the images folder in the current folder.
Example 3:
DOCTYPE html>
Relative File Path
Output:
Explanation:
In the above example, we are using relative file path when the required file is located in the folder one level up from the current folder.