<?php
class Debug
{
    private $beginTime;
    private $loads = [];

    public function __construct()
    {
        $this->beginTime = microtime();
    }

    public function add($name, $file, $line)
    {
        $file_parts = explode('\\', $file);
        $file_name = $file_parts[count($file_parts) - 1];

        $this->loads[$name] = [
            'time' => microtime(),
            'file' => $file_name,
            'line' => $line
        ];
    }

    public function toInt($time)
    {
        $time = explode(' ', $time); 
        return $time[1] + $time[0];
    }

    public function show()
    {
        $return = "<table width=100%>";

        foreach ($this->loads as $var => $value) {
            $return .= "<tr><td>" . ($this->toInt($value['time']) - $this->toInt($this->beginTime)) . "sn<td><td>$var</td><td>{$value['file']}({$value['line']})</td></tr>";
        }

        $line = __LINE__;
        $return .= "<tr><td>" . ($this->toInt(microtime()) - $this->toInt($this->beginTime)) . "sn<td><td>end</td><td>debug.php($line)</td></tr>";
        $return .= "</table>";
        $return = '<script>__debug = window.open("","DEBUG","width=680,height=600,resizable,scrollbars=yes");
        __debug.document.write(\'' . $return . '\');
        __debug.document.close();</script>';

        echo $return;
    }
}

$debug = new Debug();
$debug->add('hello', 'my.txt', 'Lorem ipsum dolor sit amet');
$debug->show();