您可以从PHP中的方法中获取方法名称吗? [英] Can you get a method name from within a method in PHP?
本文介绍了您可以从PHP中的方法中获取方法名称吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有可能做这样的事情吗?
public function something() {
$thisMethodName = method_get_name();
}
method_get_name()
在哪里返回方法的名称?
解决方案
当然,您需要魔术常数.
function myFunction() { print __FUNCTION__." in ".__FILE__." at ".__LINE__."\n"; }
从 php手册
Is it possible to do something like this?
public function something() {
$thisMethodName = method_get_name();
}
Where method_get_name()
returns the method's name?
解决方案
Sure, you want the magic constants.
function myFunction() { print __FUNCTION__." in ".__FILE__." at ".__LINE__."\n"; }
Find out more from the php manual
这篇关于您可以从PHP中的方法中获取方法名称吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文