www.webdeveloper.com
Recent Articles
  • Finding Slow Running Queries in ASE 15
  • A More Advanced Pie Chart for Analysis Services Data
  • Adobe AIR Programming Unleashed: Working with Windows
  • Performance Testing SQL Server 2008's Change Data Capture Functionality
  • The ABC's of PHP: Introduction to PHP
  • How to Migrate from BasicFiles to SecureFiles Storage
  • Why the Twitter Haters Are Wrong
  • User Personalization with PHP: Beginning the Application
  • Whats in an Oracle Schema?
  • Lighting Enhancement in Photoshop
  •  

    Go Back   WebDeveloper.com > Server-Side Development > PHP

    PHP Discussion and technical support for using and deploying PHP based websites.

    Reply
     
    Thread Tools Search this Thread Rate Thread Display Modes
      #1  
    Old 05-23-2007, 03:37 PM
    OM2 OM2 is offline
    Registered User
     
    Join Date: Apr 2005
    Posts: 402
    how can i find the absolute path from a script?

    is it possible for a script to give it's absolute path?
    i want to put a script somewhere and be able for it to reports its own absolute path.

    thanks.


    om
    Reply With Quote
      #2  
    Old 05-23-2007, 05:37 PM
    Crucial Crucial is offline
    Registered User
     
    Join Date: Apr 2007
    Posts: 25
    Try _SERVER["PATH_TRANSLATED"]

    You could also run php_info(); and review the PHP Variables section.
    Reply With Quote
      #3  
    Old 05-23-2007, 05:55 PM
    NogDog's Avatar
    NogDog NogDog is online now
    High Energy Magic Dept.
     
    Join Date: Aug 2004
    Location: Ankh-Morpork
    Posts: 14,009
    You can use the "magic" constant __FILE__ (note that it both begins and ends with double underscores).
    __________________
    "That's what the gods are! An answer that will do! Because there's food to be caught and babies to be born and life to be lived and so there is not time for big, complicated, and worrying answers! Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be." -- from Nation, by Terry Pratchett
    freelancer.internet.com
    Email me
    Reply With Quote
      #4  
    Old 05-23-2007, 06:57 PM
    OM2 OM2 is offline
    Registered User
     
    Join Date: Apr 2005
    Posts: 402
    sorry, you misunderstand what i want.
    i want the internet web address.

    so if a file sits in: http://www.mydomain/dir1/subdir

    this is exactly what i want: http://www.mydomain/dir1/subdir
    (it doesn't matter if i get back an ip number, as long as i can identify the exact directory with path.)

    also... i tried: <?php echo _SERVER["PATH_TRANSLATED"] ?>

    this didn't work.
    (i'm a newbie to php... have i typed it correctly above?)
    Reply With Quote
      #5  
    Old 05-23-2007, 07:07 PM
    Sheldon's Avatar
    Sheldon Sheldon is offline
    www.inboxdesign.co.nz
     
    Join Date: Feb 2005
    Location: Tauranga
    Posts: 2,053
    try this (Notice the $)
    PHP Code:
    <?php
    $path
    = "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
    echo(
    $path);
    ?>
    __________________
    Auckland, New Zealand, Web Design & Hosting. - Inbox Design

    Sheldon Lendrum, Technology, PHP, Mootools & More...

    Simple Site a Completely Dynamic site using text files, PHP and no mySQL.
    Reply With Quote
      #6  
    Old 05-23-2007, 08:06 PM
    OM2 OM2 is offline
    Registered User
     
    Join Date: Apr 2005
    Posts: 402
    brilliant.
    nearly what i wanted.
    i wanted just the path without the calling filename itself.

    i'm sure i can string manipulate to get rid of the filename...
    but is there a better way?
    thanks.
    Reply With Quote
      #7  
    Old 05-23-2007, 08:30 PM
    NogDog's Avatar
    NogDog NogDog is online now
    High Energy Magic Dept.
     
    Join Date: Aug 2004
    Location: Ankh-Morpork
    Posts: 14,009
    PHP Code:
    $path = "http://" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']);
    __________________
    "That's what the gods are! An answer that will do! Because there's food to be caught and babies to be born and life to be lived and so there is not time for big, complicated, and worrying answers! Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be." -- from Nation, by Terry Pratchett
    freelancer.internet.com
    Email me
    Reply With Quote
      #8  
    Old 05-23-2007, 08:44 PM
    OM2 OM2 is offline
    Registered User
     
    Join Date: Apr 2005
    Posts: 402
    Thank You!
    Reply With Quote
    Reply

    Bookmarks


    Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
     
    Thread Tools Search this Thread
    Search this Thread:

    Advanced Search
    Display Modes Rate This Thread
    Rate This Thread:

    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is Off
    HTML code is Off
    Forum Jump


    All times are GMT -5. The time now is 03:38 PM.



    Acceptable Use Policy


    The Network for Technology Professionals

    Search:

    About Internet.com

    Legal Notices, Licensing, Permissions, Privacy Policy.
    Advertise | Newsletters | E-mail Offers

    Powered by vBulletin® Version 3.7.3
    Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.