您好,欢迎访问一九零五行业门户网

php基类 调试类 错误类

错误
_conn = $conn; 
        $this->_debug = whxbb_debug_flag; 
    }
/** 
     * 处理字符串 
     * @param $str 要处理的字符串 
     * @param $act in 将'替换成\’out 把\’替换成' 
  * @access public 
     */ 
    function operatestring(&$str, $act) 
    { 
        if($act == 'in') 
            $str = str_replace(', \\’, $str); 
        if($act == 'out') 
            $str = str_replace(\\’, ', $str); 
    } 
    /** 
     * 判断一个变量是否为错误对象 
     * 
     * @param   $data   要判断的变量 
     * @access  public 
     * @return  bool    是 true 不是 false 
     */ 
    function iserror($data) { 
        return (bool)(is_object($data) && 
                      (get_class($data) == whxbb_error || 
                       is_subclass_of($data, whxbb_error)); 
    } 
    /** 
     * 判断一个变量是否为分页对象 
     * 
     * @param   $data   the value to test 
     * @access  public 
     * @return  bool    true if $data is an pager 
     */ 
    function ispager($data) { 
        return (bool)(is_object($data) && 
                      (get_class($data) == pager || 
                       is_subclass_of($data, pager)); 
    } 
}
/** 
* 调试类 

* purpose 

* 程序调试用 

* @author  : wxhbb(whxbb@21cn.com) 
* @version : 0.1 
* @date    :  2001/8/4 
*/ 
class whxbb_debug extends whxbb 

    function whxbb_debug($msg) 
    { 
        $this->whxbb(); 
        if($this->_debug == 1) 
        { 
            echo \n
whxbb debug >>> $msg
\n; 
        }     
    } 

/** 
* purpose 
* 错误处理(触发错误,显示错误) 

* @author  : whxbb(whxbb@21cn.com) 
* @version : 0.1 
* @date    :  2001/8/4 
*/ 
class whxbb_error extends whxbb 

    /** 
     * 错误信息 
     * @access protected 
     */ 
    var $_errno; 
    /** 
     * 错误代码 
     * @access protected 
     */ 
    var $_errmsg; 
    /** 报错方式 参见出错代码的预定义 */ 
    var $_reportmethod;
/** 
     * 构造一个错误对象 
     * @param $errmsg   错误信息, 错误的字符描述 
     * @param $errno    错误代码, 错误的代码 
     * @param $reportmethod 报错方式,参见出错代码的预定义 
     * @param $param1 参数一,如跳转到指定页面时页面的url 
     * @param $param2 参数二 保留 
     * @access public 
     */ 
    function whxbb_error($errmsg, $errno, $reportmethod = whxbb_error_ignore, $param1 = ', $param2 = ') 
    { 
        $this->whxbb(); 
        $this->_errmsg = $errmsg; 
        $this->_errno = $errno; 
        $this->_reportmethod = $reportmethod; 
        switch($reportmethod) 
        { 
            case whxbb_error_ignore: 
                break; 
            case whxbb_error_echo: 
                echo $errmsg; 
                break; 
            case whxbb_error_alert: 
                js::alert($errmsg); 
                break; 
            case whxbb_error_die: 
                $this->close(); 
                exit; 
                break; 
            case whxbb_error_die + whxbb_error_alert: 
                js::alert($errmsg); 
                $this->close(); 
                exit; 
                break; 
            case whxbb_error_die + whxbb_error_echo: 
                echo $errmsg; 
                $this->close(); 
                exit; 
                break; 
            case whxbb_error_alert + whxbb_error_return: 
                js::alert($errmsg); 
                js::back(); 
                break; 
            case whxbb_error_return: 
                js::back(); 
                break; 
            case whxbb_error_goto: 
                js::goto($param1); 
                break; 
            case whxbb_error_goto + whxbb_error_alert: 
                js::alert($errmsg); 
                js::goto($param1); 
                break; 
        } 
        new whxbb_debug($errno.:.$errmsg); 
    } 
    /** 
     * 得到错误对象的错误信息 
     */ 
    function getmsg() 
    { 
        return $this->_errmsg; 
    } 
    /** 
     * 得到错误对象的错误代买 
     */ 
    function getno() 
    { 
        return $this->_errno; 
    } 

?>
其它类似信息

推荐信息