Home  >  Article  >  Backend Development  >  How to get the current function name in php

How to get the current function name in php

王林
王林Original
2020-07-29 14:10:152561browse

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).

How to get the current function name in php

__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  &#39;函数名为:&#39; . __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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn