|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
use of relative links
Hi guys,
I am a little confuse of using relative links.. by given the following case public_html->myfolder1->myfolder2->myfolder3->myfolder4 - if i have a file in myfolder2 and i want to include a file in myfolder1.. is it i use ./filename or ../fielname ?? - how about if i have a file in myfolder4 and i wanna include a file in myfolder3.. is it i need to use ../filename or do i need to include the folder name as well ? - is it ../ means back to one folder ? if yes, how about ./ and when we are using relative links, do we need to include the folder name of the file as well ? - if i have a file in myfolder3 and i wanna include a file in a sub folder of myfolder1 by assuming it is called myfolder1a, is it i need to use ../../myfolder1/filename or ../../myfolder1/myfolder1a/filename? i am very confuse about using relative links when including a file. Hope you guys can give me an idea about this. Thank you. |
|
#2
|
||||
|
||||
|
Dot-dot (..) means go up one directory. Dot (.) means the current directory. You can string dot-dots together to go up multiple directories. So to go from myfolder to to a file in myfolder1, you'd do ../filename. You'd do the same if you're in myfolder4 and you want to include a file from myfolder3. In both cases, the dot-dot means to go up one directory. If you're in myfolder3 and you want to include file myfolder1a from folder myfolder1, you'd use ../../myfolder1a/filename. You're going up two folders so that you're in myfolder1, and then descending into myfolder1a from there to include your file.
|
|
#3
|
|||
|
|||
|
thanks for your info...
another thing i wanna ask.. one dot is for current directory right ?? is that mean if my current file is in folderA and i wanna include a file in a sub folder of folderA.. i need to do like ./images/finename ? but right now, i just use image/filename and it works fine... is it optional for me either add ./ or nothing when i wanna include a file in the same folder ? please advise. |
|
#4
|
||||
|
||||
|
Yes, the single dot is typically optional. It's used most often when you're running programs from the command line in *NIX.
|
![]() |
| Viewing: Dev Articles Community Forums > Programming > General Programming Help > use of relative links |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|