public function pageEntry($inPath) { /* */ SError::$CONSOLE = true; /* */ SError::$LOG = false; /* */ SError::$LOGFILE = "/tmp/tmp_serror.log"; echo $DDJFK; function test($B) { test2($B); } function test2($a) { echo "{$B}.{$a}"; //throw new Exception("D2D"); //throw new Exception("DD"); } echo "D"; test("FJKE", "E"); throw new Exception("DD"); echo "D"; //test("B","c"); }
function clear() { global $SError; if (!isset($SError)) { SError::create(); } $SError->_errors = array(); return false; }
static function error_handler($errno, $errstr, $errfile, $errline) { if (SError::$CONSOLE) { echo SError::getErrorHtml(debug_backtrace()); } if (SError::$LOG) { $log = SError::getErrorText(debug_backtrace()); if (!empty(SError::$LOGFILE)) { error_log($log, 3, SError::$LOGFILE); } else { error_log($log); } } }
function getErrors() { return SError::getErrors(); }
<?php /* * 是否在前端显示,默认为true */ SError::$CONSOLE = true; /* * 是否记log,默认记在error_log记的地方 */ SError::$LOG = false; /* * 指定log记在文件里,只有用SError::$LOG=true时,这个才有意义 */ SError::$LOGFILE = "/tmp/tmp_serror.log"; /* * 下面是测试代码 */ echo $DDJFK; function test($B) { test2($B); } function test2($a) { echo "{$B}.{$a}"; //throw new Exception("D2D"); //throw new Exception("DD"); } echo "D"; test("FJKE", "E"); throw new Exception("DD");