Re: Quick question regarding getcwd() and directory location.

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

 



Luke, i am looking for local directory info. Not URL info as i said before.

And Ashley, as i said in the original mail. I had tried $_SERVER.
Thanks for the reply though.

Ólafur Waage

2008/8/23 Luke <tinmachin3@xxxxxxxxxxxxxx>:
> $_REQUEST?
>
> Luke Slater
> Lead Developer
> NuVoo
>
> On 23 Aug 2008, at 12:53, "Ólafur Waage" <olafurw@xxxxxxxxx> wrote:
>
>> Robert, thanks for the reply but i had tried __FILE__ and __DIR__
>> (which is dirname(__FILE__)) but it doesnt work.
>>
>> 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 <robert@xxxxxxxxxxxxx>:
>>>
>>> On Fri, 2008-08-22 at 22:13 -0400, Eric Butera wrote:
>>>>
>>>> On Thu, Aug 21, 2008 at 8:50 PM, Ólafur Waage <olafurw@xxxxxxxxx> 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
>>
>

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



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux