Ólafur Waage schreef:
Robert, thanks for the reply but i had tried __FILE__ and __DIR__
(which is dirname(__FILE__)) but it doesnt work.

__DIR__ only came into existence very recently IIRC,

realpath(dirname(__FILE__)); will tell you what directory the
*current script* is actually living in ... anything $_SERVER won't
help you as is, although it might seem to under certain conditions.

your looking to determine what the directory is of the script that
was originally called by the webserver, after any magic URL rewriting, etc
has taken place ... this is actually a PITA to do under certain situations,
and by the sounds of it your trying to build something that will work
regardless.

I run into this stuff before and ended up have to generate the information
myself based on various values like $_SERVER["DOCUMENT_ROOT"], 
$_SERVER["PATH_INFO"]
and $_SERVER["REQUEST_URI"].

to be clear, your not looking for 'the current directory' but rather
something more vague i.e. 'the local absolute path to the directory
that maps to the URL that the user requested' (the code to determine that
will probably be as annoying to grok as that last sentence ;-)


And thanks for the reply also Ashley but as i said in my first post, i
had tried $_SERVER with limited results

Ólafur Waage

2008/8/23 Robert Cummings <[EMAIL PROTECTED]>:
On Fri, 2008-08-22 at 22:13 -0400, Eric Butera wrote:
On Thu, Aug 21, 2008 at 8:50 PM, Ólafur Waage <[EMAIL PROTECTED]> wrote:
I'll throw out an example here.

I have a directory structure of: /var/www/example/
And in that i have a file: index.php
That file echo's getcwd() and returns: /var/www/example/

Now i tell Apache or Lighty that if a directory does not have an
index.php file, that it should use /example/index.php (for example via
DirectoryIndex of Apache)

Then i make a new directory: /var/www/test/
And browse to it and it echo's /var/www/example/ since its running
that file via DirectoryIndex

This is true for all directories i make. Both for Windows and Linux
based servers.

To my question.

I am trying to get the full path of the current directory i am in. Not
from where the file is executing. How is that possible so it displays
a full path to that directory (regardless to the server setup)?

I have tried a variation of things and have gotten mixed results.
Using $_SERVER["SCRIPT_FILENAME"] gives me the index file and the full
path to that.
$_SERVER["DOCUMENT_ROOT"] gets me part of the way but on a hosted
server with multiple domains it only gives me a partial path (rough
example: /var/www/ when the directory is /var/www/domain.com/test/)
And __FILE__ gives me the index.php's path.
I have also tried realpath(".");
And server("pwd"); with no luck.

Any help would be appreciated.

Ólafur Waage

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Maybe dirname(__FILE__) will help.
When I'm looking for candidates to determine stuff like this I usually
do print_r( $_SERVER ) and see what's what.

Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP





--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to