PHP

How to print the function name using magic constant __FUNCTION__ in PHP | PHP programs

How to print the function name using magic constant __FUNCTION__ in PHP | PHP programs

How to print the function name using magic constant __FUNCTION__ in PHP | PHP programs

We will print the name of the function using the magic constant __FUNCTION__ . The __FUNCTION__ constant returns case sensitive function name.

<?php
  

    class Sample
    {
        public function MyFunction()
        {
            print("Function Name: ".__FUNCTION__."<br>");
        }
    }
    
    $S=new Sample();
    $S->MyFunction();
?>
TutorialsLink Curator

This is an official account managed by the team TutorialsLink Community