Bu soru burada zaten bir cevabı var:
Ben bir çözüm debug_backtrace
a> kullanmak olabilir varsayalım.
Verilen örnek, böyle bir hata izleme raporu alır:
array(2) {
[0]=>
array(4) {
["file"] => string(10) "/tmp/a.php"
["line"] => int(10)
["function"] => string(6) "a_test"
["args"]=>
array(1) {
[0] => &string(6) "friend"
}
}
[1]=>
array(4) {
["file"] => string(10) "/tmp/b.php"
["line"] => int(2)
["args"] =>
array(1) {
[0] => string(10) "/tmp/a.php"
}
["function"] => string(12) "include_once"
}
}
Peki, ne istediğinizi içermelidir ;-)
And if you just want to output the trace (not likely), there is also debug_print_backtrace
.
Benim sitelerde kullanıyorum fonksiyonu:
<!DOCTYPE HTML>
<html>
<head>
<title>Determine what line a function was executed from</title>
</head>
<body>
<?php
function linea($string1, $linea, $string2 = NULL)
{
$string2 = !empty($string2) ? $string2 : '';
return $string1 . $linea . $string2;
}
echo linea('Error: ', __LINE__) . '<br />';
/*
...
lot of code
...
*/
echo linea('Alert -> ', __LINE__, '!') . '<br />';
?>
</body>
</html>
Çıkışlar:
Error: 13
Alert -> 19!