如何在 PHP 中获取调用函数/方法的名称? [英] How to get name of calling function/method in PHP?
本文介绍了如何在 PHP 中获取调用函数/方法的名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我知道函数 debug_backtrace
,但我正在寻找一些现成的函数实现,例如 GetCallingMethodName()
?如果它也给出方法的类就完美了(如果它确实是一个方法).
I am aware of function debug_backtrace
, but I am looking for some ready to use implementation of function like GetCallingMethodName()
? It would be perfect if it gave method's class too (if it is indeed a method).
推荐答案
debug_backtrace()
函数是了解这一点的唯一方法,如果您很懒惰,这也是您应该编写代码的另一个原因GetCallingMethodName()
自己.与懒惰作斗争!:D
The debug_backtrace()
function is the only way to know this, if you're lazy it's one more reason you should code the GetCallingMethodName()
yourself. Fight the laziness! :D
这篇关于如何在 PHP 中获取调用函数/方法的名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文