Get the current path ...

Discussion in 'PHP' started by redhits, Aug 14, 2009.

  1. #1
    How i can get the current path in the PHP ?

    Like

    c:\www\hi5_adder

    or ?

    /home/pinkguy/hi5_adder (in linux) ?!
     
    redhits, Aug 14, 2009 IP
  2. shallowink

    shallowink Well-Known Member

    Messages:
    1,218
    Likes Received:
    64
    Best Answers:
    2
    Trophy Points:
    150
    #2
    echo $_SERVER['DOCUMENT_ROOT'];

    or did you want the current script's path?
     
    shallowink, Aug 14, 2009 IP
  3. redhits

    redhits Notable Member

    Messages:
    3,023
    Likes Received:
    277
    Best Answers:
    0
    Trophy Points:
    255
    #3
    the curent script path ...
     
    redhits, Aug 14, 2009 IP
  4. kblessinggr

    kblessinggr Peon

    Messages:
    539
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    0
    #4
    realpath('./');

    Course the full path for the current script including the script filename is pulled with $_SERVER['SCRIPT_FILENAME'] ('SCRIPT_NAME' pulls just the filename)

    You could always put php.php on your sever and inside of it put <? phpinfo(); ?> and goto it in the browser if you want to see all your PHP settings and all the possible $_SERVER['...'] values
     
    kblessinggr, Aug 14, 2009 IP
  5. rahahm33

    rahahm33 Well-Known Member

    Messages:
    197
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    125
    #5
    read up on $_SERVER values
     
    rahahm33, Aug 15, 2009 IP
  6. joebert

    joebert Well-Known Member

    Messages:
    2,150
    Likes Received:
    88
    Best Answers:
    0
    Trophy Points:
    145
    #6
    $dir = dirname(__FILE__);
    Code (markup):
     
    joebert, Aug 15, 2009 IP