How do I get the function name inside a function in PHP?

前端 未结 4 1558
盖世英雄少女心
盖世英雄少女心 2020-12-02 05:12

Is it possible?

function test()
{
  echo \"function name is test\";
}
4条回答
  •  盖世英雄少女心
    2020-12-02 05:39

    You can use the magic constants __METHOD__ (includes the class name) or __FUNCTION__ (just function name) depending on if it's a method or a function... =)

提交回复
热议问题