Determine the system base directory

33 views
Skip to first unread message

conmulligan

unread,
Apr 5, 2008, 3:56:06 PM4/5/08
to Professional PHP Developers
Hello all,

I need to determine if a PHP system is running in a directory, for
example www.example.com/my/dir.

It needs to detect the directory no matter how deep, so if its located
in www.example.com/dir it will get dir or if its in www.example.com/dir/dir
it will get dir/dir.

I've tried numerous solutions for this, but no joy so far.

Any ideas?

Krumphau

unread,
Apr 6, 2008, 9:32:32 AM4/6/08
to Professional PHP Developers
The solution is really quite simple

<?php
$directory = dirname(__FILE__);
$filename = basename(__FILE__);
print "This script is called $filename and resides in $directory.";
?>



Reply all
Reply to author
Forward
0 new messages