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

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

Is it possible?

function test()
{
  echo \"function name is test\";
}
4条回答
  •  不思量自难忘°
    2020-12-02 05:44

    The accurate way is to use the __FUNCTION__ predefined magic constant.

    Example:

    class Test {
        function MethodA(){
            echo __FUNCTION__;
        }
    }
    

    Result: MethodA.

提交回复
热议问题