path_join( string $base, string $path ): string

Joins two filesystem paths together.

Description

For example, ‘give me $path relative to $base’. If the $path is absolute, then it the full path is returned.

Parameters

$basestringrequired
Base path.
$pathstringrequired
Path relative to $base.

Return

string The path with the base or absolute path.

Source

function path_join( $base, $path ) {
	if ( path_is_absolute( $path ) ) {
		return $path;
	}

	return rtrim( $base, '/' ) . '/' . $path;
}

Changelog

VersionDescription
2.5.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.