php将命名常量定义为函数名

How to create a dynamic function name dependent on a defined named constant?

eg:

define('NAME1','func1');

function NAME1($arg) {
    echo "function 1 $arg
";
    print __FUNCTION__." in ".__FILE__." at ".__LINE__."
";
};

NAME1("helllo");

this echos function name as "NAME1" - why is it not func1?

The closest thing that I can think of is to use PHP 5.3 anonymous functions (other than using eval)

define('NAME1', 'my_function');
$func_name = NAME1;
$$func_name = function($arg) {
   // Your code
};
$my_function('test');

You can't do that.

this echos function name as "NAME1" - why is it not func1?

because you defined your function name as NAME1.