How to parse a variable before the include

Discussion in 'PHP' started by bobby9101, Aug 17, 2007.

  1. #1
    Hi, I am using dirname($_SERVER['SCRIPT_FILENAME']); and including the file in other files. the way it is now, it gets the directory of the file that is calling the include. I want it to use the directory of the file that is being included.
    How do I do this?
    Thanks
     
    bobby9101, Aug 17, 2007 IP
  2. bilal@revolutionhosting

    bilal@revolutionhosting Peon

    Messages:
    32
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    bilal@revolutionhosting, Aug 17, 2007 IP
  3. bobby9101

    bobby9101 Peon

    Messages:
    3,292
    Likes Received:
    134
    Best Answers:
    0
    Trophy Points:
    0
    #3
    No, I don't want to use __FILE__
     
    bobby9101, Aug 17, 2007 IP
  4. bilal@revolutionhosting

    bilal@revolutionhosting Peon

    Messages:
    32
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    It would seem to work in the situation you described, and provide you with the desired results.
    Is there any specific reason you'd prefer not to use the __FILE__ constant?
     
    bilal@revolutionhosting, Aug 17, 2007 IP
  5. bobby9101

    bobby9101 Peon

    Messages:
    3,292
    Likes Received:
    134
    Best Answers:
    0
    Trophy Points:
    0
    #5
    I changed from $_SERVER[SCRIPT_FILENAME] to http:// . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']}
    So __FILE__ Does not achieve the correct results.
     
    bobby9101, Aug 17, 2007 IP