选择显示字体大小

基类 调试类 错误类


<?php
//
// +----------------------------------------------------------------------+
// whxbb 基类
// +----------------------------------------------------------------------+
// copyright (c) 2001.netfish software
//
// author: whxbb(whxbb@21cn.com)
// +----------------------------------------------------------------------+
//
// &#36;id: whxbb.class.php,v 0.1 2001/8/4 12:53:33 yf exp &#36;
//
// 禁止直接访问该页面
if (basename(&#36;http_server_vars['php_self']) == &quot;whxbb.class.php&quot;) {
header(&quot;http/1.0 404 not found&quot;);
}

// 调试标志,为1时,系统运行在调试状态
define('whxbb_debug_flag', 0);

// 出错代码的预定义
// 忽略错误
define('whxbb_error_ignore', 1);
// 在页面显示错误
define('whxbb_error_echo' , 2);
// 弹出错误警告并显示错误
define('whxbb_error_alert' , 4);
// 停止程序的运行
define('whxbb_error_die'  , 8);
// 返回上页
define('whxbb_error_return', 16);
// 跳到指定页
define('whxbb_error_goto', 32);

/**
* purpose
* 基类, 在该类中封装了一些常用的方法
*
* @author : whxbb(whxbb@21cn.com)
* @version : 0.1
* @date : 2001/12/4
*/
class whxbb
{
/**
 * 调试标志
 * @access protected
 */
var &#36;_debug;
/**
 * 数据库连接标志
 * @access protect
 */
var &#36;_conn;

function whxbb()
{
// 数据库连接标志
global &#36;_conn;
if (!is_resource(&#36;conn))
die(&quot;数据库连接错误&quot;);
&#36;this->_conn = &#36;conn;
&#36;this->_debug = whxbb_debug_flag;
}

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

/**
* 调试类
*
* purpose
*
* 程序调试用
*
* @author : wxhbb(whxbb@21cn.com)
* @version : 0.1
* @date : 2001/8/4
*/
class whxbb_debug extends whxbb
{
function whxbb_debug(&#36;msg)
{
&#36;this->whxbb();
if(&#36;this->_debug == 1)
{
echo &quot;\n<br>whxbb debug >>> &#36;msg<br>\n&quot;;
}
}
}
/**
* purpose
* 错误处理(触发错误,显示错误)
*
* @author : whxbb(whxbb@21cn.com)
* @version : 0.1
* @date : 2001/8/4
*/
class whxbb_error extends whxbb
{
/**
 * 错误信息
 * @access protected
 */
var &#36;_errno;
/**
 * 错误代码
 * @access protected
 */
var &#36;_errmsg;
/** 报错方式 参见&quot;出错代码的预定义&quot; */
var &#36;_reportmethod;

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

  


 


关键字 本文所属关键字

相关 与本文相关文章

分类 所有文章关键字导航

源码编程相关

Java   Asp   PHP   .Net   XML   C/C++   CGI   VB   Jsp   J2ee   J2se   J2me   EJB   Servlet   Tomcat   Resin   Struts   Weblogic   Eclipse   ANT   GUI   JMS   Web servise   IDEA   Webphere   Hibernate   Spring   Jboss   Applet   Swing   Socket   Javamail   Perl   Ajax   P2P   安全   模式   框架   测试   开源   游戏

SQL数据库相关

My-SQL   Ms-SQL   Access   DB2   Oracle   Sybase   SQLserver   索引   存储过程   加密   数据库   分页   视图  

手机无线相关

3G   Wap   CDMA   GRPS   GSM   IVR   彩信   短信   无线   增值业务

网页设计制作相关

HTML   CSS   网页配色   网页特效   Javascript   VBscript   Dreamweaver   Frontpage   JS   Web   网站设计

网站建设推广相关

建站经验   网站优化   网站排名   推广   Alexa

操作系统/服务器相关

Windows XP   Windows 2000   Windows 2003   Windows Me   Windows 9.x   Linux   UNIX   注册表   操作系统   服务器   应用服务器

图形图像多媒体相关

Photoshop   Fireworks   Flash   Coreldraw   Illustrator   Freehand   Photoimpact   多媒体   图形图像

标准 网站致力的规范

Valid CSS!

无不良内容,无不良广告,无恶意代码

Valid XHTML 1.0 Transitional

creativecommons