FILE and LINE are your friends. Not sure why this is but when I first started with PHP I never made much use of these constants, how wrong I was! These babies have saved me hours of painful work since I began adding them to my error handling. They are great for tracking down tricky bugs.
For you new programmers FILE gives the full path name of the file where it’s used and LINE of course gives you the exact line your on. You do need to be careful because if you use these in a function they will return the file name of the file the function is declared in and line of declaration as opposed to the file and line where you called the function, which is probably what you really wanted. I often work around this limitation by passing file and line into a generic error handling function. Example: