wp_normalize_path

Normalize a filesystem path.

Description

(string) wp_normalize_path( (string) $path ); 

On windows systems, replaces backslashes with forward slashes and forces upper-case drive letters. Allows for two leading slashes for Windows network shares, but ensures that all other duplicate slashes are reduced to a single.

Returns (string)

Normalized path.

Parameters (1)

0. $path (string)
Path to normalize.

Usage

  1. if ( !function_exists( 'wp_normalize_path' ) ) { 
  2. require_once ABSPATH . WPINC . '/functions.php'; 
  3.  
  4. // Path to normalize. 
  5. $path = ''; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = wp_normalize_path($path); 
  9.  

Defined (1)

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

/wp-includes/functions.php  
  1. function wp_normalize_path( $path ) { 
  2. $path = str_replace( '\\', '/', $path ); 
  3. $path = preg_replace( '|(?<=.)/+|', '/', $path ); 
  4. if ( ':' === substr( $path, 1, 1 ) ) { 
  5. $path = ucfirst( $path ); 
  6. return $path;