关于文件路径

发布于 2024-11-14 08:28:02 字数 379 浏览 3 评论 0原文

文件的路径有相对路径和绝对路径。但有些文章有时让我感到困惑:

/a/b/c.php   //relative document root
./a/b/c.php  //what does this mean? equals to '/a/b/c.php' or a/b/c.php?

a/b/c.php    //relative to current directory
../a/b/c.php  //parent folder relative to current directory
/../a/b/c.php  //what does this mean? parent folder of document root?

还有其他写法吗?

谢谢。

There are relative path and absolute path of the a file. But some of the writings confuse me sometimes:

/a/b/c.php   //relative document root
./a/b/c.php  //what does this mean? equals to '/a/b/c.php' or a/b/c.php?

a/b/c.php    //relative to current directory
../a/b/c.php  //parent folder relative to current directory
/../a/b/c.php  //what does this mean? parent folder of document root?

Are there other ways of writing this?

Thank you.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

少女净妖师 2024-11-21 08:28:02

这里有一些基本的目录符号:

  • .(点)是当前目录
  • ..(双点)是当前目录的父目录
  • ~(波形符)是您的主目录。
  • /(斜杠)如果它出现在第一个字符,通常称为根目录。

这些都来自linux/unix术语(这里是CMIIW)。

现在,让我们看一下实现:

  • 假设您在 /home/username/
  • ,如果您编写如下内容,结果是:
    1. ./wwwroot/somedir/ => /home/用户名/wwwroot/somedir/
    2. ../wwwroot/somedir/ => /home/wwwroot/somedir/
    3. /../wwwroot/somedir/ => /wwwroot/somedir

您可能会对示例 #3 感到困惑。如果在路径信息前面加上/,则表示您位于根目录。因此,如果你写 /../somedir/ 则意味着你指向 /somedir/。为什么?因为根目录没有父目录。

Here's some basic directory symbol for you:

  • . (dot) is your current directory
  • .. (double-dot) is the parent of your current directory
  • ~ (tilde) is your home directory.
  • / (slash) if it present at first character, it usually is called root directory.

These all came from linux / unix terminology (CMIIW here).

Now, let's take a look at the implementation:

  • Let's say, you are on /home/username/
  • if you write something like this, the result is:
    1. ./wwwroot/somedir/ => /home/username/wwwroot/somedir/
    2. ../wwwroot/somedir/ => /home/wwwroot/somedir/
    3. /../wwwroot/somedir/ => /wwwroot/somedir

You might get confused on example #3. If you put / in front of path info, it mean you are at the root directory. Therefore, if you write /../somedir/ it mean, you are pointing to /somedir/. Why? because root directory doesn't have parent.

过期以后 2024-11-21 08:28:02

。 = 当前目录。因此 ./a/b/c.php 相当于 a/b/c.php

/../a/b/c.php 表示先到根目录,然后上一层,再到目录a,再到目录b ,然后是c.php

. = current directory. So ./a/b/c.php would be equivalent to a/b/c.php.

/../a/b/c.php means go to the root directory, then up one, then directory a, then directory b, then c.php.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文