• 25-12-2022, 11:47:09
    #1
    Başlıkta belirttiğim hata error loga yazılıyor ve o bölümdeki kod dizimi;

    <?php
    class debug{
        function add($name,$file,$line){
            $this->load[$name]=array("time"=>microtime(),"file"=>end(explode("\\",$file)),"line"=>$line);
        }
        function toint($time){
            $time = explode(" ", $time); 
            return $time[1] + $time[0];
        }
        function show(){
            $return="<table width=100%>";
            foreach($this->load as $var=>$value){
                $return .="<tr><td>" .($this->toint($value["time"])-$this->toint(BEGIN_TIME))."sn<td><td>".$var."</td><td>".$value["file"]."(".$value["line"].")</td></tr>";
            }
            $return .="<tr><td>" .($this->toint(microtime())-$this->toint(BEGIN_TIME))."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;
        }
    }
    Yardımlarınızı bekliyorum.
  • 25-12-2022, 11:54:04
    #2
    4. satırda array atadığın için hata vermiş.
  • 27-12-2022, 23:25:34
    #3
    <?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();
  • 31-12-2022, 15:38:34
    #4
    problem end fonkisyonunda
    explode işlemini herhangi bir değişlene tanımladıktan sonra end çalıştırırsanız notice vermeyecektir.
    $exp = explode("\",$file);
    end($exp)
    gibi