/../ 或 "/../" 在文件系统中是什么意思?

what does /../ or "/../" mean in file system?

我知道。指当前目录,./ 指当前目录中的文件。 我也知道 .. 指的是父目录

最近我看到了下面一行:

require __DIR__.'/../vendor/autoload.php';

(它在 laravel 的 index.php 文件中。)

这里具体“/../”是什么意思?

谢谢

编辑:我尝试在 google 上搜索。我也尝试使用转义序列进行搜索,例如 //..//,但没有给出所需的答案。

你是这样读的:

__DIR__      // start in the current directory
../          // go up one directory from where you are
vendor/      // go into the vendor directory
autoload.php // and require the autoload.php file

__DIR__../ 之间的额外 / 只是为了确保当前目录以斜杠结尾,所以你得到,例如 code/../vendor/autoload.php 而不是 code../vendor/autoload.php

在路径中,. 指当前(工作)目录,.. 指父目录(如果存在)。两者都是 "shortcuts" 用于实际写入这些目录的名称(例如,如果您不知道 current/parent 目录的名称):这是一个示例:

如果您在文件夹 /root 中:

1  ./test        //--> points to folder 'test' (relative path)
2  /root/test    //--> points to folder 'test' (absolut path)

两者是平等的。如果你在文件夹 /root/test:

1  ./..          //--> points to folder 'root' (relative path)
2  /root         //--> points to folder 'root' (absolut path)

../ 上到父目录然后在项目/ 之前../

的同一根目录下
require __DIR__.'/../vendor/autoload.php';

引用当前路径的父目录(如果父目录存在则诅咒)

基本上,/../没有任何具体定义,因为它是__DIR__.'/../vendor/autoload.php'的一部分,由../vendor/autoload.php组成。其中 .. 表示返回当前父目录,稍后告诉您进入或 cdvendor 目录然后继续 autoload.php,以及与 [=20= 相关的所有内容].

示例:

假设您想 gedit 从当前目录结构如下

的另一个目录中的文件
/home/handsomeyou/Documents/Code/ -> your current directory
/home/hansdomeyou/Documents/Tasks/task_list.txt -> your target

有很多方法可以实现这一点,但为了使其与您的问题相关,我们将这样做

$ gedit ../Tasks/task_list.txt