Determine What Line a Function Was Executed From
<p>I'm trying to build an error class and a lot of error classes I've looked at in the past use <strong>FILE</strong> and <strong>LINE</strong> to show where the error occurred, but they use them in the function so they're always the same, which is highly useless information. Aside from sending an array of containing <strong>FILE</strong> and <strong>LINE</strong> with every function (which would get to be quite a pain), I can't think of or find anything else. Is there a good way or a function out there to determine the correct line number and file that the function was being executed from?</p>

<p>Example:</p>

<pre><code>&lt;?php
// file1.php
dosomething(false);
?&gt;

&lt;?php
// file2.php
function dosomething($input) {
    if ($input === false) die("Error at Line (line) in File (file)");
}
?&gt;
</code></pre>

<p>The function would die with the message "Error at Line 3 in File <em>/file1.php</em>".</p>
