php tell me directory

__DIR__
does not work

__FILE__
tells me filename

but I want the directory that I am in (minus filename)
LVL 1
rgb192Asked:
Who is Participating?
 
DjRedCommented:
You have a few options on this one...

The first is if the code you are using IS in the directory of the file you are using then there is no need to list the directory.....


Example:
Say you are in the directory "html/www/testDIR/"
and you had a file in it: "html/www/testDIR/test.php"

then you can easily in that test.php file declare the file you need without the current directory like so:
$filename = "testfilename.php";

and that will be the same as: "html/www/testDIR/testfilename.php"

or use an alternative like so:

<?php
// current directory
echo getcwd();
?>

Open in new window

0
 
p_nutsCommented:
How about this

http://www.php.net/manual/en/function.pathinfo.php

$patharr = pathinfo(__FILE__);

Echo $patharr['dirname'];
0
 
rgb192Author Commented:
thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.