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

How to get the current function name in php

王林
Release: 2023-03-03 13:32:01
Original
2620 people have browsed it

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();
?>
Copy after login

Output result:

函数名为:test
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template