wp_basename

I18n friendly version of basename().

Description

(string) wp_basename( (string) $path, (string) $suffix = '' ); 

Returns (string)

Parameters (2)

0. $path (string)
The path.
1. $suffix — Optional. (string) => ''
If the filename ends in suffix this will also be cut off.

Usage

  1. if ( !function_exists( 'wp_basename' ) ) { 
  2. require_once ABSPATH . WPINC . '/formatting.php'; 
  3.  
  4. // The path. 
  5. $path = ''; 
  6.  
  7. // If the filename ends in suffix this will also be cut off. 
  8. $suffix = ''; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = wp_basename($path, $suffix); 
  12.  

Defined (1)

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

/wp-includes/formatting.php  
  1. function wp_basename( $path, $suffix = '' ) { 
  2. return urldecode( basename( str_replace( array( '%2F', '%5C' ), '/', urlencode( $path ) ), $suffix ) );