__FUNCTION__
__FUNCTION__ holds the current function or method name.
The function name includes the namespace it was declared in, e.g. N\X\foo. It also uses the definition’s case.
When used inside a method, __FUNCTION__ is the name of the method it is used in. When used outside a function, this constant holds an empty string, and does not emit any warning.
__METHOD__ and __FUNCTION__ are almost identical.
This constant is written in uppercase, by convention. It is case insensitive, and may be used with any combination of uppercase and lower case.
<?php
function trumpet() {
echo __FUNCTION__; // trumpet
}
function STAMPEDE() {
echo __function__; // STAMPEDE
}
class Elephpant {
function trumpet() {
echo __FUNCTION__; // trumpet
}
}
trumpet();
(new Elephpant)->trumpet();
?>