Absolute vs. relative pathnames

Discussion in 'HTML & Website Design' started by star2323, Dec 12, 2005.

  1. #1
    Is there any advantages or disadvantages of using absolute pathnames vs. relative pathnames?

    The problem I'm having is when I use the php include to include an html file which has image paths in it. The file path is not always the same depending on where the file with the php include is located.

    Is there a way to use relative path names without knowing where the file will be located? Or should I just use absolute pathnames?
     
    star2323, Dec 12, 2005 IP
  2. Amsterdam

    Amsterdam Well-Known Member

    Messages:
    361
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    128
    #2
    If I didn't know where the file was located then I would use absoloute pathnames. Is there another way around it?

    T
     
    Amsterdam, Dec 13, 2005 IP
  3. star2323

    star2323 Peon

    Messages:
    445
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I don't know how to get around it. Since I want to use the same header and footer for all my pages but the pages which are including the header and footer are not all in the same directory.

    Any ideas?
     
    star2323, Dec 13, 2005 IP
  4. mdvaldosta

    mdvaldosta Peon

    Messages:
    4,079
    Likes Received:
    362
    Best Answers:
    0
    Trophy Points:
    0
    #4
    You can use relative and start it from site root. as in /images would be root/images. Only drawback thou is when using that for a php includes command you usually have to do /home/user/etc. or /../../filename or whatever.
     
    mdvaldosta, Dec 13, 2005 IP
  5. star2323

    star2323 Peon

    Messages:
    445
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Is there a way in PHP to get the root directory?

    So you could do something link:

    <?php ROOT ?>/images/pic.jpg

    And it would work no matter where the file was at?
     
    star2323, Dec 13, 2005 IP