PHP program to print the method name with the associated class name using magic constant __METHOD__

bookmark

<?php
    //PHP program to print the method name with the 
    //associated class using magic constant __METHOD__.
    class Sample
    {
        public function MyMethod()
        {
            print(__METHOD__."<br>");
        }
    }
    
    $S=new Sample();
    $S->MyMethod();
?>


Output
Sample::MyMethod