SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    Jan 2009
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Getting url of the current directory?

    Hi,

    How do you get the URL to the running php script?

    For example:

    http://www.example.com/path/to/script/file/script.php

    I want to get:

    /path/to/script/file/

    Raj

  2. #2
    SitePoint Enthusiast
    Join Date
    Jan 2009
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Found it!
    Code:
    $parseinfo = parse_url($_SERVER['REQUEST_URI']);
    echo $parseinfo['path'];

  3. #3
    SitePoint Zealot
    Join Date
    Sep 2008
    Location
    Bristol ,England
    Posts
    177
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    To get the current working directory you echo getcwd() and that will show the complete path

  4. #4
    SitePoint Zealot
    Join Date
    Sep 2008
    Location
    Bristol ,England
    Posts
    177
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry I think I misunderstood what you wanted.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •