mmm... in some cases, but not always. In my example if you do
index.php
<?php
        include "/path/to/file_a.php";
?>
using $_SERVER['SCRIPT_FILENAME'] in do_something() will return /path/ 
to/index.php, but I really want /path/to/file_a.php which is the file  
calling the function defined in file_b.php... makes sense?



On 2/10/2008, at 9:59 AM, Nathan Kennedy wrote:


Hey Matt,

If I understand your question correctly, I think you'll find that
$_SERVER['SCRIPT_FILENAME'] will contain the value that you are after.

Thanks,
Nathan.
Web Controlled Robotic Arm and Beetle
http://www.kennedytechnology.com


-----Original Message-----
From: [email protected] [mailto:[EMAIL PROTECTED] On  
Behalf
Of Matias Gertel
Sent: Thursday, 2 October 2008 9:20 a.m.
To: NZ PHP Users Group
Subject: [phpug] dirname of file with calling function


Hi all,
I've been wondering... I'm a big fan of dirname(__FILE__) but
sometimes I have a situation where I would like to know the path of
the file where my function is called.
I'll explain:
file_a.php is:
<?php
        include "/path/to/file_b.php";
        do_something();
?>
file_b.php is:
<?php
        function do_something() {
                // I wonder what's the dirname of file_a.php ?
        }
?>

I know this can be done using debug_backtrace but it's not really
ideal. I was wondering if someone had this situation and solved it in
some elegant way.

Cheers,

Matt








--~--~---------~--~----~------------~-------~--~----~
NZ PHP Users Group: http://groups.google.com/group/nzphpug
To post, send email to [email protected]
To unsubscribe, send email to
[EMAIL PROTECTED]
-~----------~----~----~----~------~----~------~--~---

Reply via email to