有没有办法在php中获取被调用的函数/方法名称? 我想知道我的函数调用了哪种方法,在PHP中有这样的方法吗?
您可以考虑以下示例,以便更清楚地了解我想要实现的目标。
示例:
class abc {
function fruit() {
echo 'fruit method called';
// can i get information from which method this method is being called
// SAMPLE OUTPUT
// METHOD CALLED FROM fruit_nested_method -> fruit_another_nested_method
}
function fruit_nested_method() {
echo $this->fruit();
}
function fruit_another_nested_method() {
echo $this->fruit_nested_method();
}
}