Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Relative path using "./"

Tags:

path

php

Im working with some code that uses "./" to describe a path to the stylesheet in the header.

<link rel="stylesheet" href="./public/css/style.css">

I am familiar with "../" - go up one level and follow path from there

and "/" - follow path from root directory

It seems "./" is a relative path but why use it at all? Why not just write the path as public/css/style.css

like image 650
Mary624 Avatar asked Apr 01 '26 19:04

Mary624


1 Answers

./ means relative to the current directory.

You are correct, the two ways of writing the path are exactly the same and both will work fine.

Using ./ may help in the case that a script generates the path.

like image 67
phpchap Avatar answered Apr 04 '26 10:04

phpchap



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!