PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I'm using trigger_error within a class, however the line PHP outputs is the line of code trigger_error() is called at within the class. Is there a way to get it to output the line the class function was called on, as well as the file? For example:
class test
{
function myfunc()
{
trigger_error( 'My error message' ) // <-- I don't want this line
}
}
test::myfunc() // <--- would it be possible to return this line number?
If I have to abandon the trigger_error function that is fine, but I'd prefer similar functionality. Thanks for the help.
And then call trigger_error() from that function. You dont get the exact line number but it is very close to it, and costum error message usually makes things clear.
I also like to add a configuration check for development or debug status and if it is turned on use debug_backtrace() for debugging in same function.
makes my life a lot easier and plus you can control error message formating and stuff...