class Path (View source)

Path manipulation helpers

Constants

TRIM_CHARS

Methods

public static 
string
join(array ...$parts)

Joins one or more paths, normalising all separators to DIRECTORY_SEPARATOR

public static 
string
normalise(string $path, bool $relative = false)

Normalise absolute or relative filesystem path.

Details

static string join(array ...$parts)

Joins one or more paths, normalising all separators to DIRECTORY_SEPARATOR

Note: Errors on collapsed /../ for security reasons. Use realpath() if you need to join a trusted relative path.

Parameters

array ...$parts

Return Value

string

Combined path, not including trailing slash (unless it's a single slash)

See also

\SilverStripe\Core\File::join_paths() for joining file identifiers

static string normalise(string $path, bool $relative = false)

Normalise absolute or relative filesystem path.

Important: Single slashes are converted to empty strings (empty relative paths)

Parameters

string $path

Input path

bool $relative

Return Value

string

Path with no trailing slash. If $relative is true, also trim leading slashes