lists.zerezo.com



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

***BOGO*** Re: [PHP] Quick question regarding getcwd() and directory location.



How are you browsing to it from within PHP? Depending on how you are
doing it, the way to get the cwd is different

Ash
www.ashleysheridan.co.uk
--- Begin Message ---
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


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