Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Retrieving the name of the current function in PHP [duplicate]

Tags:

function

php

Is there a function that can return the name of the current function a program is executing?

like image 602
Cian E Avatar asked Jan 22 '10 08:01

Cian E


1 Answers

Yes, you can get the function's name with the magic constant __FUNCTION__

class foo {   function print_func()   {             echo __FUNCTION__;   }   function print_method()   {             echo __METHOD__;   } }  $obj = new foo(); $obj->print_func();      // Returns: print_func $obj->print_method();    // Returns: foo::print_method 
like image 84
Sarfraz Avatar answered Oct 06 '22 12:10

Sarfraz