Is ./path necessary?
<link rel="icon" href="./favicon.ico" type="image/x-icon" />
The above is what I see in index.php of phpMyAdmin.
Isn't it the same as:
<link rel="icon" href="favicon.ico" type="image/x-icon" /&g开发者_运维百科t;
Or say, can you give an example where these two generates different results?
Same thing, no advantage of one over the other, just personal preference.
The convention of using ./foo stems from when foo is an executable script and ./ is not in your default path. For just looking up files, as in your example, there is no difference.
They are the same. In fact, the ./
will be removed anyways (see RFC 3986 – 5.2.4. Remove Dot Segments):
2. While the input buffer is not empty, loop as follows: A. If the input buffer begins with a prefix of "../" or "./", then remove that prefix from the input buffer; otherwise, …
Those two paths are exactly the same. They are appended after the lastmost directory separator. So for http://example.com/site/index.html, the URL will become either http://example.com/site/./favicon.ico or http://example.com/site/favicon.ico. But when those URL's are normalized, both will result in http://example.com/site/favicon.ico because any /./ in a path will be replaced with / when normalizing.
In general I would use the second version.
It is just a matter of choice, as i like
<img src="./dir/myimage.jpg" />
over
<img src="dir/myimage.jpg" />
精彩评论