I'm trying to build an error class and a lot of error classes I've looked at in the past use FILE and LINE 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 FILE and LINE 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?
Example:
<?php
// file1.php
dosomething(false);
?>
<?php
// file2.php
function dosomething($input) {
if ($input === false) die("Error at Line (line) in File (file)");
}
?>
The function would die with the message "Error at Line 3 in File /file1.php".
Duplicate of Get code line and file that’s executing the current function in PHP?