Re: Which file called the function?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This should work:

global.php
<?
  function myFunc($file) { echo $file; }
?>

one.php
<?
  include( 'global.php' );
  echo 'You are in file: ';
  myFunc(__FILE__);
?>

two.php
<?
  include( 'global.php' );
  echo 'You are in file: ';
  myFunc(__FILE__);
?>
Christoph Boget wrote:
> 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
> 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux