tags:

views:

52

answers:

2

in file.php:

call()...

How to get absolute path of file.php inside call() ?

Pay attention that call() may be defined in another file.

another.php:

function call(){..}

file.php:

include(path_to_another.php);
call();
+2  A: 

You can also get the basename for the file, like so;

basename(__FILE__);

Hope this helps!

James Brooks
+3  A: 

no way except debug_backtrace

function whatever() {
    $t = debug_backtrace();
    echo "called from {$t[0]['file']}";
}
stereofrog