public static function realpath($path)
    {
        $path = str_replace(DIRECTORY_SEPARATOR, '/', $path);

        if (false === $parse_url = parse_url($path)) {
            return false;
        }

        if (!array_key_exists('host', $parse_url)) {
            return realpath($path);
        }

        if (!array_key_exists('scheme', $parse_url)) {
            return false;
        }

        $parts = [];
        $pathArray = explode('/', str_replace(DIRECTORY_SEPARATOR, '/', $parse_url['path']));

        foreach ($pathArray as $part) {
            if ('.' === $part) {
                continue;
            } elseif ('..' === $part) {
                array_pop($parts);
            } else {
                $parts[] = $part;
            }
        }

        $path = (isset($parse_url['scheme']) ? $parse_url['scheme'].'://' : '').
                (isset($parse_url['user']) ? $parse_url['user'] : '').
                (isset($parse_url['pass']) ? ':'.$parse_url['pass'] : '').
                (isset($parse_url['user']) || isset($parse_url['pass']) ? '@' : '').
                (isset($parse_url['host']) ? $parse_url['host'] : '').
                (isset($parse_url['port']) ? ':'.$parse_url['port'] : '').
                implode('/', $parts);

        if (!file_exists($path)) {
            return false;
        }

        return $path;
    }
public static function realpath($path)
    {
        $path = str_replace(DIRECTORY_SEPARATOR, '/', $path);

        if (false === $parse_url = parse_url($path)) {
            return false;
        }

        if (!array_key_exists('host', $parse_url)) {
            return realpath($path);
        }

        if (!array_key_exists('scheme', $parse_url)) {
            return false;
        }

        $parts = [];
        $pathArray = explode('/', str_replace(DIRECTORY_SEPARATOR, '/', $parse_url['path']));

        foreach ($pathArray as $part) {
            if ('.' === $part) {
                continue;
            } elseif ('..' === $part) {
                array_pop($parts);
            } else {
                $parts[] = $part;
            }
        }

        $path = (isset($parse_url['scheme']) ? $parse_url['scheme'].'://' : '').
                (isset($parse_url['user']) ? $parse_url['user'] : '').
                (isset($parse_url['pass']) ? ':'.$parse_url['pass'] : '').
                (isset($parse_url['user']) || isset($parse_url['pass']) ? '@' : '').
                (isset($parse_url['host']) ? $parse_url['host'] : '').
                (isset($parse_url['port']) ? ':'.$parse_url['port'] : '').
                implode('/', $parts);

        if (!file_exists($path)) {
            return false;
        }

        return $path;
    }
public static function realpath ( $ path ) { $ path = str_replace ( DIRECTORY_SEPARATOR , '/' , $ path ) ; if ( false === $ parse_url = parse_url ( $ path ) ) { return false ; } if ( ! array_key_exists ( 'host' , $ parse_url ) ) { return realpath ( $ path ) ; } if ( ! array_key_exists ( 'scheme' , $ parse_url ) ) { return false ; } $ parts = [ ] ; $ pathArray = explode ( '/' , str_replace ( DIRECTORY_SEPARATOR , '/' , $ parse_url [ 'path' ] ) ) ; foreach ( $ pathArray as $ part ) { if ( '.' === $ part ) { continue ; } elseif ( '..' === $ part ) { array_pop ( $ parts ) ; } else { $ parts [ ] = $ part ; } } $ path = ( isset ( $ parse_url [ 'scheme' ] ) ? $ parse_url [ 'scheme' ] . '://' : '' ) . ( isset ( $ parse_url [ 'user' ] ) ? $ parse_url [ 'user' ] : '' ) . ( isset ( $ parse_url [ 'pass' ] ) ? ':' . $ parse_url [ 'pass' ] : '' ) . ( isset ( $ parse_url [ 'user' ] ) || isset ( $ parse_url [ 'pass' ] ) ? '@' : '' ) . ( isset ( $ parse_url [ 'host' ] ) ? $ parse_url [ 'host' ] : '' ) . ( isset ( $ parse_url [ 'port' ] ) ? ':' . $ parse_url [ 'port' ] : '' ) . implode ( '/' , $ parts ) ; if ( ! file_exists ( $ path ) ) { return false ; } return $ path ; }
Returns canonicalized absolute pathname
@param  string         $path
@return boolean|string
Returns canonicalized absolute pathname