How to get the function name inside a function in php?

To get the function name inside the PHP function we need to use Magic constants(__FUNCTION__).

1. Code:

<?php
function Soltuts() { 
    // Magic function constant which
    // holds the function name, or 
    // {closure} for anonymous functions
    $string = __FUNCTION__;   
    // Display the result
    echo $string;
}
  
// Function call
Soltuts();
?>

2. Example:

Input:

function Soltuts()

Output:

The function name:
Soltuts

3. Syntax:

Syntax:
$string = __FUNCTION__
Description: This constant is used to return the function name, or {closure} for anonymous functions.

To get the function name inside the PHP function we need to use Magic constants(FUNCTION) or Magic constants(METHOD).
Magic constants: Magic constants are the predefined constants in PHP which is used on the basis of their use. These constants are starts and end with a double underscore (__). These constants are created by various extensions.