figuring out where you are in an included file
| From: | chagenbu at wso dot williams dot edu | Date: | Sun, 28 May 2000 02:59:26 +0000 |
| Subject: | figuring out where you are in an included file | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-19627@lists.php.net to get a copy of this message | ||
So, in the course of trying to write a factory method for a Log abstraction
class that I'm working on, I figured out that it would be nice to figure out
where I am on the filesystem - not just where the main script is, but where I am
when I'm in an included file, like a library, that might be included from lots
of different places.
I figured out that this:
substr(__FILE__, 0, -(strlen(basename(__FILE__))))
... seems to give me a path, that even if it's relative, is relative to the
original script, which means that I can use it in include/require lines - which
is pretty much what I need, which is fine.
My question is, am I crazy to depend on this, and am I missing any other way of
getting the same information?
-chuck