Function Name In A Method

no-email (Damien Seguy), Damien Seguy
Tue, 29 Apr 2025 00:00:00 +0000

The magic constants give information on the context of execution of the code. ``__METHOD__`` gives the name of the method, and its related class. ``__CLASS__`` gives the name of the current class, whatever the method. And ``__FUNCTION__`` gives the name of the curent function, or, also, the name of the method, though without the name of the class.
Basically, ``__METHOD__ === __CLASS__ .'::'. __FUNCTION__``.
Also, just for fun, you can also use ``__METHOD__`` in a function, and you'll get the same as ``__FUNCTION__``. The opposite, as we can see, is not true.