path_join() WordPress Function

The path_join() function is used to join two or more path segments together. It takes an arbitrary number of parameters and returns a single string.

path_join( string $base, string $path ) #

Join 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.


Top ↑

Parameters

$base

(string)(Required)Base path.

$path

(string)(Required)Path relative to $base.


Top ↑

Return

(string) The path with the base or absolute path.


Top ↑

Source

File: wp-includes/functions.php

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

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


Top ↑

Changelog

Changelog
VersionDescription
2.5.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More
Show More