What difference in ./ ../ /

2020-06-06 07:50发布

I serched around but didn't get satisfactory answer. In directory structure i want to know what is the use of ./
It doest impact if I use this in src.
Please let us know difference in ./ ../ and /

标签: php html
5条回答
一夜七次
2楼-- · 2020-06-06 08:06

./ is the current directory.

../ is the parent directory of current directory.

/ is the root directory of the system.

查看更多
放荡不羁爱自由
3楼-- · 2020-06-06 08:11

If this is about URLs, as it seems – the HTML attribute src takes a URL value – then it really has nothing to with directories. Interpretation of relative URLs takes place as string manipulation, without any reference to directories or files. (A resolved URL, absolute URL, may then be interpreted in a manner that maps things to a file system, but that is a different issue.)

At the start of a URL,

./ has no effect (it is removed in interpreting a relative URL)

../ causes the last part of the base URL, back to its last / in it, to be removed before using it as a prefix

/ causes the URL to be prefixed by the protocol and server part of the current base URL

Thus, assuming a base URL of http://www.example.com/foo/bar/zap,

./test.html resolves to the same as test.html, namely http://www.example.com/foo/bar/test.html

../test.html resolves to http://www.example.com/foo/test.html

/test.html resolves to http://www.example.com/test.html

Reference: STD 66.

If it happens that the absolute URLs are then interpreted, by the server running at www.example.com, in a simplistic (and common) manner by mapping them to a file system, then ./ maps to the same directory as the base URL, ../ maps to its parent directory, and / maps to the server root.

查看更多
ゆ 、 Hurt°
4楼-- · 2020-06-06 08:13

They work like this:

  • ./ — the current directory
  • ../ — the parent directory of the current directory
  • / — the root directory of the file system
查看更多
Luminary・发光体
5楼-- · 2020-06-06 08:18

./ means the current directory

../ means the parent of the current directory, not the root directory

/ is the root directory

Explanation

myfile.text is in the current directory, as is ./myfile.text

../myfile.text is one level above you and /myfile.text lives in your root directory.

查看更多
Explosion°爆炸
6楼-- · 2020-06-06 08:24

./ is the current directory.

../ is the parent directory of current directory.

/ is the root directory of the system.

You can also use __FILE__ and __DIR__ to get the path.

For more details look at this constants predefined

查看更多
登录 后发表回答