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

Breadcrumb

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

function Path::isAbsolute

Same name in this branch
  1. 11.1.x vendor/php-tuf/composer-stager/src/Internal/Path/Value/Path.php \PhpTuf\ComposerStager\Internal\Path\Value\Path::isAbsolute()
3 calls to Path::isAbsolute()
Path::isRelative in vendor/symfony/filesystem/Path.php
Path::makeAbsolute in vendor/symfony/filesystem/Path.php
Turns a relative path into an absolute path in canonical form.
PathHelper::isAbsolute in vendor/php-tuf/composer-stager/src/Internal/Path/Service/PathHelper.php

File

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

Class

Path
Contains utility methods for handling path strings.

Namespace

Symfony\Component\Filesystem

Code

public static function isAbsolute(string $path) : bool {
    if ('' === $path) {
        return false;
    }
    // Strip scheme
    if (false !== ($schemeSeparatorPosition = strpos($path, '://')) && 1 !== $schemeSeparatorPosition) {
        $path = substr($path, $schemeSeparatorPosition + 3);
    }
    $firstCharacter = $path[0];
    // UNIX root "/" or "\" (Windows style)
    if ('/' === $firstCharacter || '\\' === $firstCharacter) {
        return true;
    }
    // Windows root
    if (\strlen($path) > 1 && ctype_alpha($firstCharacter) && ':' === $path[1]) {
        // Special case: "C:"
        if (2 === \strlen($path)) {
            return true;
        }
        // Normal case: "C:/ or "C:\"
        if ('/' === $path[2] || '\\' === $path[2]) {
            return true;
        }
    }
    return false;
}

API Navigation

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