This question already has an answer here:
I've looked this up and I know that the answer probably involves the use of debug_backtrace()
, but I am struggling on how to use it or exactly what it does.
Basically, if this was index.php:
<?php
//some code
//some more code
require "functions.php";
print_line();
//some code
print_line();
?>
and functions.php was:
<?php
function print_line(){
$line="[line that this function was called at]";
print "This function was called from line $line of index.php<br />";
}
?>
What would be the correct way of setting $line
so that the output would be:
This function was called from line 7 of index.php
This function was called from line 11 of index.php
</div>