Skip to content

Instantly share code, notes, and snippets.

<?php
$backtrace = debug_backtrace();
array_shift($backtrace);
foreach($backtrace as $k => $v) {
if(is_array($v) && isset($v['file']) && isset($v['line'])) {
preg_match("/.*\/([^\/]*)$/", $v['file'], $matches);
$fileName = $matches[1];
$filePath = str_replace($fileName, '', $matches[0]);
$string = 'file:'.$filePath."\e[36m".$fileName." \033[32m line:".$v['line'];
echo $string."\033[0m\n";