Home  >  Article  >  Backend Development  >  javascript - windows中这样的路径表什么意思: d:/ecshop/mobile/../data/config.SegmentFault

javascript - windows中这样的路径表什么意思: d:/ecshop/mobile/../data/config.SegmentFault

WBOY
WBOYOriginal
2016-06-06 20:08:331088browse

<code>这样的路径的含义是什么? :
  d:/ecshop/mobile/../data/config.php
config.php这个文件的实际路径是:
  d:/ecshop/data/config.php

我知道: 
  ./data/config.php 表示当前打开的文件的目录下的data目录中的config.php这个文件
  ../data/config.php 表示当前打开的文件的上级目录下的data目录中的config.php这个文件

第一次见过: d:/ecshop/mobile/..data/config.php 这样的路径,不知道该怎样看这样的路径??


求科普.....
</code>

回复内容:

<code>这样的路径的含义是什么? :
  d:/ecshop/mobile/../data/config.php
config.php这个文件的实际路径是:
  d:/ecshop/data/config.php

我知道: 
  ./data/config.php 表示当前打开的文件的目录下的data目录中的config.php这个文件
  ../data/config.php 表示当前打开的文件的上级目录下的data目录中的config.php这个文件

第一次见过: d:/ecshop/mobile/..data/config.php 这样的路径,不知道该怎样看这样的路径??


求科普.....
</code>

你可以这样想象,初始时有一个指针指向根目录,然后从左往右读路径,遇到一个文件夹名加斜杠fold/就把指针指向下一层目录,遇到../就把指针指回当前目录的上一层目录,遇到./则不改变指针指向。

d:/ecshop/mobile/../data/config.php就是d:/ecshop/data/config.php

任何目录下都有两个特殊的目录 ...
. 表示当前目录
.. 表示上一级目录

哪个文件夹下的 .. 就是表示那个文件夹的父文件夹。
直接写.. 的话,搜索路径默认是当前路径,也就是说是用的当前目录的..,所以此时 .. 就表示当前文件夹的上一级目录。

因此 d:/ecshop/mobile/../data/config.php 表示 d:/ecshop/data/config.php

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn