Created
February 25, 2016 05:13
-
-
Save codeachange/a8176a07452749d4cb81 to your computer and use it in GitHub Desktop.
debug class for php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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').' '.$_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