获取下层函数名
程序员文章站
2022-05-10 13:44:31
...
获取上层函数名
------解决方案--------------------
(
[0] => Array
(
[file] => D:\AMP\web\ide_tmp.php
[line] => 5
[function] => display
[class] => ex
[object] => ex Object
(
)
[type] => ->
[args] => Array
(
)
)
[1] => Array
(
[file] => D:\AMP\web\ide_tmp.php
[line] => 13
[function] => demo
[class] => ex
[object] => ex Object
(
)
[type] => ->
[args] => Array
(
)
)
)
class ex {
public function demo()
{
$this->display();
}
public function dispaly()
{
// 我在这里要获取调用本方法的 demo 函数名,有什么办法??
}
}
------解决方案--------------------
class ex {Array
public function demo() {
$this->display();
}
public function display() {
// 我在这里要获取调用本方法的 demo 函数名,有什么办法??
print_r(debug_backtrace());
}
}
$p = new ex;
$p->demo();
(
[0] => Array
(
[file] => D:\AMP\web\ide_tmp.php
[line] => 5
[function] => display
[class] => ex
[object] => ex Object
(
)
[type] => ->
[args] => Array
(
)
)
[1] => Array
(
[file] => D:\AMP\web\ide_tmp.php
[line] => 13
[function] => demo
[class] => ex
[object] => ex Object
(
)
[type] => ->
[args] => Array
(
)
)
)
相关文章
相关视频