Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Path.php

function Path::getExtension

Returns the extension from a file path (without leading dot).

Parameters

bool $forceLowerCase forces the extension to be lower-case:

2 calls to Path::getExtension()
Path::changeExtension in vendor/symfony/filesystem/Path.php
Changes the extension of a path string.
Path::hasExtension in vendor/symfony/filesystem/Path.php
Returns whether the path has an (or the specified) extension.

File

vendor/symfony/filesystem/Path.php, line 276

Class

Path
Contains utility methods for handling path strings.

Namespace

Symfony\Component\Filesystem

Code

public static function getExtension(string $path, bool $forceLowerCase = false) : string {
    if ('' === $path) {
        return '';
    }
    $extension = pathinfo($path, \PATHINFO_EXTENSION);
    if ($forceLowerCase) {
        $extension = self::toLower($extension);
    }
    return $extension;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal