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 | SplObjectStorage current() Function
- PHP | SimpleXMLIterator current() Function
- PHP | SplFileObject current( ) Function
- PHP | Imagick current() Function
- PHP | SplHeap current() Function
- PHP | SplFixedArray current() Function
- PHP | SplDoublyLinkedList current() Function
- Get the current URL using jQuery?
- How to get current year in PHP ?
- How to get the current weeknumber of the year?
- How to get the current date and time in seconds?
- Get name of current method being executed in Java
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.