Reputation: 13270
I want to return the name of the first file being processed in the stack.
Let me explain: I've got two files.
1) foo
:
include("bar");
2) bar
:
echo __ FILE__;
When I request foo it displays "/home/example/bar" while I'd like to see the string "/home/example/foo" happening.
How to do that?
Upvotes: 1
Views: 63
Reputation: 360662
The __FILE__
constant by design is ALWAYS the file where the constant appears, regardless of what file(s) have loaded/included this file. Try $_SERVER['SCRIPT_NAME']
instead.
Upvotes: 2
Reputation: 7656
This should do the trick:
$backtrace = debug_backtrace();
echo $backtrace[0]['file'];
http://php.net/manual/en/function.debug-backtrace.php
Upvotes: 1