makeAbsolute.php
Table of Contents
Functions
- makeAbsolute() : string
- Turns a relative path into an absolute path in canonical form.
Functions
makeAbsolute()
Turns a relative path into an absolute path in canonical form.
makeAbsolute(string $path, string $basePath) : string
This function joins a relative path with an absolute base path to create a new absolute path. It also canonicalizes the result, which means:
- Dot segments ("." and "..") are resolved.
- All directory separators are converted to forward slashes ("/").
- Redundant slashes are removed.
If the provided path is already absolute, it is simply canonicalized and returned, ignoring the base path.
The function correctly handles URI schemes (like "phar://" or "vfs://") by preserving the scheme from the base path in the final result.
Parameters
- $path : string
-
The path to resolve. Can be relative or absolute.
- $basePath : string
-
The absolute base path. Must not be empty.
Tags
Return values
string —The resulting absolute path in canonical form.