path_join

Join two filesystem paths together.

Description

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

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

Returns (string)

The path with the base or absolute path.

Parameters (2)

0. $base (string)
Base path.
1. $path (string)
Path relative to $base.

Usage

  1. if ( !function_exists( 'path_join' ) ) { 
  2. require_once ABSPATH . WPINC . '/functions.php'; 
  3.  
  4. // Base path. 
  5. $base = ''; 
  6.  
  7. // Path relative to $base. 
  8. $path = ''; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = path_join($base, $path); 
  12.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/functions.php  
  1. function path_join( $base, $path ) { 
  2. if ( path_is_absolute($path) ) 
  3. return $path; 
  4.  
  5. return rtrim($base, '/') . '/' . ltrim($path, '/');