2013-04-06 51 views
1

說我有MyClass.phpPHP:我可以在我的課程內部調用我的方法嗎?

class MyClass 
{ 
    public static function myMethod() 
    { 
     // Here I want to know the line (and file) where my method has been called 
    } 
} 

而且SomeOtherFile.php

​​

那麼,有沒有一種方式來獲得從SomeOtherFile線,其中myMethod的()已經在myMethod的直接調用?我的意思是,沒有通過線路作爲參數。

回答

4

debug_backtrace()應該做的工作:

class MyClass 
{ 
    public static function myMethod() 
    { 
     var_dump(debug_backtrace()); 
    } 
} 
+0

是的,這甚至比我需要更多。很棒的功能。 – Michael 2013-04-06 14:32:38

相關問題