The function name can be easily obtained by the __FUNCTION__ or the __METHOD__
Method 1 (Prints function name):
__FUNCTION__ is used to resolve function name or method name (function in class).
string(3) "foo" string(3) "bar"
Method 2 (Prints function and class name):
string(3) "bar" string(9) "Test::foo"
Note: this code is tested with php7.1
- PHP | current() Function
- PHP | SplFileObject current( ) Function
- PHP | SplHeap current() Function
- PHP | SplDoublyLinkedList current() Function
- PHP | SplFixedArray current() Function
- PHP | SplObjectStorage current() Function
- Get the current URL using jQuery?
- Get name of current method being executed in Java
- How to get the current date and time in seconds?
- How to get the size of screen, current web page and browser window using jQuery?
- PHP | Ds\Map xor() Function
- PHP Ds\Set sum() Function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.