RE: [PHP] Which file called the function?
| From: | Shelley Shyan | Date: | Fri, 21 Dec 2007 04:03:25 +0000 |
| Subject: | RE: [PHP] Which file called the function? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-266197@lists.php.net to get a copy of this message | ||
Richard is right.
If you want to get where __FILE__ is exactly in, __FILE__ is the option.
Else, use $_SERVER['PHP_SELF']. (And this should be what you expected)
Regards,
Shelley
-----Original Message-----
From: christoph.boget@gmail.com [mailto:christoph.boget@gmail.com] On Behalf Of Christoph Boget
Sent: Thursday, December 20, 2007 10:37 PM
To: PHP General
Subject: [PHP] Which file called the function?
Let's say I have the following 3 files
global.php
<?
function myFunc() { echo __FILE__; }
?>
one.php
<?
include( 'global.php' );
echo 'You are in file: ';
myFunc();
?>
two.php
<?
include( 'global.php' );
echo 'You are in file: ';
myFunc();
?>
In each case, what is echoed out for __FILE__ is global.php. Apart from analyzing the
debug_backtrace array, is there any way that myFunc() would display "one.php" and
"two.php" respectively?
thnx,
Christoph