tags:

views:

65

answers:

5
<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" />

Or say,can you give an example where these two generates different results?

A: 

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.

Cheatah
+1  A: 

Same thing, no advantage of one over the other, just personal preference.

Velika
Not exactly true... There is an advantage of dropping the `./`: saving 2 bytes an x amount of times.
Andrew Moore
+1  A: 

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.

Timo
+1, Best answer
Tim Post
But this does not concern relative URIs.
Gumbo
+1  A: 

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,
 …
Gumbo
A: 

It is just a matter of choice, as i like

<img src="./dir/myimage.jpg" />

over

<img src="dir/myimage.jpg" />
Rakesh Juyal