Skip to content

Instantly share code, notes, and snippets.

@farik92
Forked from antongorodezkiy/backtrace.php
Created April 28, 2025 19:03
Show Gist options
  • Select an option

  • Save farik92/cca4d01805091ee32c0d3cf6797544b3 to your computer and use it in GitHub Desktop.

Select an option

Save farik92/cca4d01805091ee32c0d3cf6797544b3 to your computer and use it in GitHub Desktop.
debug_backtrace() with files and lines only
<?php
function backtrace() {
$keys = array('file','line');
$target = array();
foreach(debug_backtrace() as $key => $s) {
/*if ($key == 0) {
continue;
}*/
foreach($s as $inner_key => $inner_s) {
if (in_array($inner_key,$keys))
$target[$key][$inner_key] = $inner_s;
}
}
return $target;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment