src/Validator.php
public static function isAbsolutePath($path) : bool
    {
        /*
         * This is definitive if true but fails if $path does not exist or contains
         * a symbolic link.
         */
        if (realpath($path) == $path) {
            return true;
        }

        if (strlen($path) == 0 || $path[0] == '.') {
            return false;
        }

        // Windows allows absolute paths like this.
        if (preg_match('#^[a-zA-Z]:\\\\#', $path)) {
            return true;
        }

        // A path starting with / or \ is absolute; anything else is relative.
        return ( $path[0] == '/' || $path[0] == '\\' );
    }
public static function isAbsolutePath($path) : bool
    {
        /*
         * This is definitive if true but fails if $path does not exist or contains
         * a symbolic link.
         */
        if (realpath($path) == $path) {
            return true;
        }

        if (strlen($path) == 0 || $path[0] == '.') {
            return false;
        }

        // Windows allows absolute paths like this.
        if (preg_match('#^[a-zA-Z]:\\\\#', $path)) {
            return true;
        }

        // A path starting with / or \ is absolute; anything else is relative.
        return ( $path[0] == '/' || $path[0] == '\\' );
    }
public static function isAbsolutePath ( $ path ) : bool { /*
         * This is definitive if true but fails if $path does not exist or contains
         * a symbolic link.
         */ if ( realpath ( $ path ) == $ path ) { return true ; } if ( strlen ( $ path ) == 0 || $ path [ 0 ] == '.' ) { return false ; } // Windows allows absolute paths like this. if ( preg_match ( '#^[a-zA-Z]:\\\\#' , $ path ) ) { return true ; } // A path starting with / or \ is absolute; anything else is relative. return ( $ path [ 0 ] == '/' || $ path [ 0 ] == '\\' ) ; }
Test if a give filesystem path is absolute.

For example, '/foo/bar', or 'c:\windows'.

@since 2.5.0

@param string $path File path.
@return bool True if path is absolute, false is not absolute.
Test if a give filesystem path is absolute .