Google News
logo
PHP program to print the function name using magic constant __FUNCTION__
In the following example of PHP program that demonstrates how to print the function name using the magic constant `__FUNCTION__` :
Program :
<?php
function printFunctionName() {
  echo "The name of this function is: " . __FUNCTION__;
}

printFunctionName();
?>
Output :
The name of this function is: printFunctionName
As you can see, the `__FUNCTION__` magic constant is replaced with the name of the function in which it appears.