tags:

views:

88

answers:

3

im creating a log function that will log my errors in a file.

i thought it will contain which class and method the error occured in.

is there a way of logging in which class and method the error occured in so i dont have to type it manually each time?

+1  A: 

get_called_class() get's the current class. This might also be interesting: debug_print_backtrace().

Thomas
not true. It get's the late static binding class.
Gordon
You're right, I forgot the context because I've just used it tomorrow. But might be interesting anyway?
Thomas
+3  A: 

I'm not big on PHP but I believe it has "magic constants" similar to C/C++. Take a look here: This seems to indicate you could use

__LINE__, __FILE__, __FUNCTION__, __CLASS__, and __METHOD__
acron
+1  A: 

use the __METHOD__ constant in PHP5

Ken