Skip to content

Instantly share code, notes, and snippets.

@codeachange
Created February 25, 2016 05:13
Show Gist options
  • Save codeachange/a8176a07452749d4cb81 to your computer and use it in GitHub Desktop.
Save codeachange/a8176a07452749d4cb81 to your computer and use it in GitHub Desktop.
debug class for php
<?php
define('DEBUG_LOG_FILE',__DIR__.'/debuglog.html');
class debug{
static function log($str){
file_put_contents(DEBUG_LOG_FILE,self::prepare_str($str));
}
static function add($str){
file_put_contents(DEBUG_LOG_FILE,self::prepare_str($str),FILE_APPEND);
}
static function dielog($str){
self::log($str);
die();
}
static function dieadd($str){
self::add($str);
die;
}
static function prepare_str($str){
return '<span>'.date('H:i:s').'&nbsp;&nbsp;&nbsp;&nbsp;'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'].'</span><pre style="font-weight:bold;">'.htmlspecialchars(print_r($str,1)).'</pre>';
}
static function output($str)
{
echo self::prepare_str($str);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment