getting base directory

I want a function that gives me the base directory of a script.

So when given the script file '/var/www/test.org/html/test/index.php' from
$_SERVER['SCRIPT_FILENAME'] it returns '/var/www/test.org/html/test/'.

I am wondering the neatest way to do this ?

I cannot find a reverse string search function.

Many thanks in advance,

Aaron
Aaron Gray [ Mi, 02 April 2008 17:59 ] [ ID #1934061 ]

Re: getting base directory

"Aaron Gray" <ang.usenet [at] gmail.com> wrote in message
news:65horiF2g0v0aU1 [at] mid.individual.net...
> I want a function that gives me the base directory of a script.
>
> So when given the script file '/var/www/test.org/html/test/index.php' from
> $_SERVER['SCRIPT_FILENAME'] it returns '/var/www/test.org/html/test/'.
>
> I am wondering the neatest way to do this ?
>
> I cannot find a reverse string search function.
>
> Many thanks in advance,
>
> Aaron
>
>

basename
Steve Foley [ Mi, 02 April 2008 18:01 ] [ ID #1934062 ]

Re: getting base directory

"Steve Foley" <steve.foley [at] att.DELETE.net> wrote in message
news:d5OIj.14899$oE1.7400 [at] trndny09...
> "Aaron Gray" <ang.usenet [at] gmail.com> wrote in message
> news:65horiF2g0v0aU1 [at] mid.individual.net...
>> I want a function that gives me the base directory of a script.
>>
>> So when given the script file '/var/www/test.org/html/test/index.php'
>> from
>> $_SERVER['SCRIPT_FILENAME'] it returns '/var/www/test.org/html/test/'.
>>
>> I am wondering the neatest way to do this ?
>>
>> I cannot find a reverse string search function.
>>
>> Many thanks in advance,
>>
>> Aaron
>>
>>
>
> basename

That was quick :)

Thanks,

Aaron
Aaron Gray [ Mi, 02 April 2008 18:03 ] [ ID #1934063 ]

Re: getting base directory

"Steve Foley" <steve.foley [at] att.DELETE.net> wrote in message
news:d5OIj.14899$oE1.7400 [at] trndny09...
> "Aaron Gray" <ang.usenet [at] gmail.com> wrote in message
> news:65horiF2g0v0aU1 [at] mid.individual.net...
>> I want a function that gives me the base directory of a script.
>>
>> So when given the script file '/var/www/test.org/html/test/index.php'
>> from
>> $_SERVER['SCRIPT_FILENAME'] it returns '/var/www/test.org/html/test/'.
>>
>> I am wondering the neatest way to do this ?
>>
>> I cannot find a reverse string search function.
>>
>> Many thanks in advance,
>>
>> Aaron
>>
>>
>
> basename

You mean dirname not basename !:)

Aaron
Aaron Gray [ Mi, 02 April 2008 18:04 ] [ ID #1934064 ]

Re: getting base directory

<comp.lang.php>
<Aaron Gray>
<Wed, 2 Apr 2008 17:04:44 +0100>
<65hpe8F2fl881U1 [at] mid.individual.net>

> > basename
>
> You mean dirname not basename !:)
>

$batman=pathinfo($doc,PATHINFO_DIRNAME);

Havent actually tried it myself - its just a snippet of code i have .


--
www.krustov.co.uk
Hans-Peter Sauer [ Mi, 02 April 2008 18:24 ] [ ID #1934066 ]

Re: getting base directory

"Krustov" <me [at] privacy.net> wrote in message
news:MPG.225dc386ad8c913b98b370 [at] news.newsreader.com...
> <comp.lang.php>
> <Aaron Gray>
> <Wed, 2 Apr 2008 17:04:44 +0100>
> <65hpe8F2fl881U1 [at] mid.individual.net>
>
>> > basename
>>
>> You mean dirname not basename !:)
>>
>
> $batman=pathinfo($doc,PATHINFO_DIRNAME);
>
> Havent actually tried it myself - its just a snippet of code i have .

It works I have used it in my utils.

Aaron
Aaron Gray [ Mi, 02 April 2008 18:35 ] [ ID #1934069 ]

Re: getting base directory

"Aaron Gray" <ang.usenet [at] gmail.com> wrote in message
news:65hpe8F2fl881U1 [at] mid.individual.net...
>
> You mean dirname not basename !:)
>
> Aaron

Yup.
Steve Foley [ Mi, 02 April 2008 19:10 ] [ ID #1934073 ]
PHP » comp.lang.php » getting base directory

Vorheriges Thema: small compatible error in mozilla
Nächstes Thema: Time GMT down