How to get the current function name in php: You can get it through the magic constant __FUNCTION__. Since PHP 5, the magic constant __FUNCTION__ is used to return the name of the function when it was defined (case-sensitive).
__FUNCTION__ returns the function name (newly added in PHP 4.3.0). Since PHP 5 this constant returns the name of the function as it was defined (case sensitive). In PHP 4 this value is always lowercase.
(Recommended tutorial: php tutorial)
Code implementation:
<?php function test() { echo '函数名为:' . __FUNCTION__ ; } test(); ?>
Output result:
函数名为:test
The above is the detailed content of How to get the current function name in php. For more information, please follow other related articles on the PHP Chinese website!