public static function path($filename, $relativeTo = null, $checkExists = true, $ds = null)
    {
        $ds = $ds ?: DIRECTORY_SEPARATOR;

        if (is_array($filename)) {
            $pathnames = array();
            foreach ($filename as $k => $f) {
                $pathnames[$k] = self::path($f, $relativeTo, $checkExists);
            }
            return $pathnames;
        }

        $relativeTo = $relativeTo ?: self::$rootDirectory;
        $pathname = $filename;
        if ($filename{0} != '/' && !preg_match('#^[A-Z]:(\\\\|/)#', $filename)) {
            if (strlen($filename) >= 2 && substr($filename, 0, 2) == './') {
                $filename = substr($filename, 2);
            }
            $pathname = rtrim($relativeTo, $ds) . $ds . $filename;
        }
        if ($checkExists) {
            return realpath($pathname);
        }
        return $pathname;
    }
public static function path($filename, $relativeTo = null, $checkExists = true, $ds = null)
    {
        $ds = $ds ?: DIRECTORY_SEPARATOR;

        if (is_array($filename)) {
            $pathnames = array();
            foreach ($filename as $k => $f) {
                $pathnames[$k] = self::path($f, $relativeTo, $checkExists);
            }
            return $pathnames;
        }

        $relativeTo = $relativeTo ?: self::$rootDirectory;
        $pathname = $filename;
        if ($filename{0} != '/' && !preg_match('#^[A-Z]:(\\\\|/)#', $filename)) {
            if (strlen($filename) >= 2 && substr($filename, 0, 2) == './') {
                $filename = substr($filename, 2);
            }
            $pathname = rtrim($relativeTo, $ds) . $ds . $filename;
        }
        if ($checkExists) {
            return realpath($pathname);
        }
        return $pathname;
    }
public static function path ( $ filename , $ relativeTo = null , $ checkExists = true , $ ds = null ) { $ ds = $ ds ? : DIRECTORY_SEPARATOR ; if ( is_array ( $ filename ) ) { $ pathnames = array ( ) ; foreach ( $ filename as $ k => $ f ) { $ pathnames [ $ k ] = self :: path ( $ f , $ relativeTo , $ checkExists ) ; } return $ pathnames ; } $ relativeTo = $ relativeTo ? : self :: $ rootDirectory ; $ pathname = $ filename ; if ( $ filename { 0 } != '/' && ! preg_match ( '#^[A-Z]:(\\\\|/)#' , $ filename ) ) { if ( strlen ( $ filename ) >= 2 && substr ( $ filename , 0 , 2 ) == './' ) { $ filename = substr ( $ filename , 2 ) ; } $ pathname = rtrim ( $ relativeTo , $ ds ) . $ ds . $ filename ; } if ( $ checkExists ) { return realpath ( $ pathname ) ; } return $ pathname ; }
Makes a filename relative to another one

@param string $filename
@param string $relativeTo
@param bool $checkExists
@return string
Makes a filename relative to another one