From: Martin G. <gim...@gi...> - 2003-01-05 14:40:44
|
"Ted Vinke" <te...@jo...> writes: Hi Ted, > I need to know the path + filename of the plugin, when a plugin is > used on a page. I can't use $PHP_SELF etc. because that would only > return the name of the Wikipage the plugin is used in, when that > page is opened. What I need is e.g. > /phpwiki/lib/plugin/<plugin-name>.php, because I need that path for > something inside a plugin I'm working on. > > Is this possible and if so, how? One way of doing it is to use the __FILE__ "constant" which always holds the name of the current file. (There's also a __LINE__ "constant" that holds the current line number, I believe they're meant for printing error-messages.) The following code gives you the path to the current file, relative to $DOCUMENT_ROOT: substr(__FILE__, strlen(realpath($HTTP_SERVER_VARS['DOCUMENT_ROOT']))) -- Martin Geisler My GnuPG Key: 0xF7F6B57B See http://gimpster.com/ and http://phpweather.net/ for: PHP Weather => Shows the current weather on your webpage and PHP Shell => A telnet-connection (almost :-) in a PHP page. |