private function basename($path)
    {
        $separators = '/';
        if (DIRECTORY_SEPARATOR != '/') {
            // For Windows OS add special separator.
            $separators .= DIRECTORY_SEPARATOR;
        }

        // Remove right-most slashes when $path points to directory.
        $path = rtrim($path, $separators);

        // Returns the trailing part of the $path starting after one of the directory separators.
        $filename = preg_match('@[^'.preg_quote($separators, '@').']+$@', $path, $matches) ? $matches[0] : '';

        return $filename;
    }
private function basename($path)
    {
        $separators = '/';
        if (DIRECTORY_SEPARATOR != '/') {
            // For Windows OS add special separator.
            $separators .= DIRECTORY_SEPARATOR;
        }

        // Remove right-most slashes when $path points to directory.
        $path = rtrim($path, $separators);

        // Returns the trailing part of the $path starting after one of the directory separators.
        $filename = preg_match('@[^'.preg_quote($separators, '@').']+$@', $path, $matches) ? $matches[0] : '';

        return $filename;
    }
private function basename ( $ path ) { $ separators = '/' ; if ( DIRECTORY_SEPARATOR != '/' ) { // For Windows OS add special separator. $ separators .= DIRECTORY_SEPARATOR ; } // Remove right-most slashes when $path points to directory. $ path = rtrim ( $ path , $ separators ) ; // Returns the trailing part of the $path starting after one of the directory separators. $ filename = preg_match ( '@[^' . preg_quote ( $ separators , '@' ) . ']+$@' , $ path , $ matches ) ? $ matches [ 0 ] : '' ; return $ filename ; }
Gets the filename from a given path.

PHP's basename() does not properly support streams or filenames beginning with a non-US-ASCII character.

@author Drupal 8.2

@param string $path

@return string
Gets the filename from a given path .