I have a function log($text)
all this does is write $text
to a database.
I would like to include __LINE__
and __FILE__
, but don't want to include it as a parameter each time as I currently do:
function log($text,$file = null, $line = null){
// write $text to db using the three paramters
}
If I change $file = null
to $file = __FILE__
it uses the file name that the function lives in, rather than where the function is being called.
Is there any way around this?
Although the question is identical, the answers seem to focus on some other topic: function name($param, $line = __LINE__, $file = __FILE__) {}; also, not using Zend framework: how to have php get the __LINE__ or __FILE__ value where a function is called