PHP自定义错误处理程序

王朝php·作者佚名  2006-01-09
窄屏简体版  字體: |||超大  

<?php

function user_define_error_handle($errorNo, $errorMessage, $errorFile = __FILE__, $errorLine = __LINE__)

{

$errorContent = "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">

<tr>

<td background=\"images/bk_head.jpg\"><img src=\"images/error.gif\"></td>

</tr>

<tr>

<td background=\"images/bk_main.jpg\">

<B>ERROR:</B> $errorMessage

<P>Please try again, or contact us and tell us that

the error occurred in line ".$errorLine." of file '".$errorFile."'";

if ($errorNo == E_USER_ERROR || $errorNo == E_ERROR)

{

$errorContent .= "<P>This error was fatal, program ending";

$errorContent .= "</td></tr></table><br>";

echo $errorContent;

exit;

}

$errorContent .= "</td></tr></table><br>";

echo $errorContent;

//在此还可以加入其它的功能如发一封邮件给技术支持人员etc.

Mail();

}

set_error_handler("user_define_error_handle");

fopen("gotodie", "r");//触发错误

trigger_error(“Trigger function called”, E_USER_NOTICE);

?>

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航