1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Calculating the websites root directory

Discussion in 'PHP' started by zaphod2003, May 20, 2007.

  1. #1
    Hi there, PHP newbie here.

    How do I define a global variable to point to the root of a web site so that I can navigate from anywhere to anywhere, without having to specify it (i.e. PHP works it out

    For example:

    <?php
    global siteRoot = "the website's URL"
    ?>
    PHP:
    Where
     siteRoot 
    Code (markup):
    for example would pick up http://forums.digitalpoint.com it was running on this site.


    I want to be able to write code like:

    include_once $siteRoot."\includes\sub\sub\file.inc"
    Code (markup):
    for example.

    Unless I'm missing can't see this in PHPINFO()

    Is there an easy way ?
     
    zaphod2003, May 20, 2007 IP
  2. dp-user-1

    dp-user-1 Well-Known Member

    Messages:
    794
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    110
    #2
    dp-user-1, May 20, 2007 IP
  3. zaphod2003

    zaphod2003 Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks man, I was looking for the hard way I think. Did not realise it would be THAT simple!!! :D
     
    zaphod2003, May 20, 2007 IP
  4. dp-user-1

    dp-user-1 Well-Known Member

    Messages:
    794
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    110
    #4
    :) No problem. And global variables are generally frowned upon, so I would start right now coding without them.

    -Peter
     
    dp-user-1, May 20, 2007 IP