You can check the stack trace debug_backtrace(). This will contain information about the calling method / function among others. See the manual for examples.
To add behavior to an existing function, wrap the function in your own function or class, and then call it instead of the built-in function.
, runkit. runkit_redefine_function() ( APD, ).
, mail(), . , IDE. Eclipse, Zend Studio Netbeans , , .