[英]Exception handling problems in php
我正在为我的项目尝试PHP异常。 但是事实证明,该异常被成功引发,但是没有被我编写的代码成功捕获。
编码:
try{
require_once(MASTER_PHP."/master_validation.php");
require_once(MASTER_PHP."/master_user.php");
require_once(MASTER_PHP."/master_db.php"); require_once(MASTER_PHP."/master_secure.php");
require_once(MASTER_PHP."/master_ui.php");
require_once(MASTER_PHP."/master_mail.php");
require_once(MASTER_PHP."/master_filehandling.php");
require_once(MASTER_PHP."/master_archive.php");
require_once(MASTER_PHP."/master_date.php");
require_once(MASTER_PHP."/master_social.php");
require_once(MASTER_PHP."/master_message.php");
require_once(MASTER_PHP."/master_gallery.php");
require_once(MASTER_PHP."/master_backup.php");
require_once(MASTER_PHP."/master_payment.php");
require_once(MASTER_PHP."/master_sms.php");
require_once(MASTER_PHP."/master_xml.php");
$filterobj=new ta_filtervalue();
$filterobj->filterrequest();
global $noecho;
if($noecho!="yes")
{
$utilityobj=new ta_utilitymaster();
$utilityobj->includeextassets();
}
}
catch (Exception $e)
{
$custerrcode=$e->getMessage();
$dbobj=new ta_dboperations();
$res=$dbobj->dbquery("SELECT * FROM ".ERROR_CODES." WHERE ".errordb_errcode."='$custerrcode' LIMIT 0,1",DB_ERROR);
$errmsg=$res[0][changesqlquote(errordb_errdesc,"")];
$errpriority=$res[0][changesqlquote(errordb_errpriority,"")];
$errcallback1=$res[0][changesqlquote(errordb_errcallback1,"")];
$errcalltext1=$res[0][changesqlquote(errordb_errcallbacktext1,"")];
$errcallback2=$res[0][changesqlquote(errordb_errcallback2,"")];
$errcalltext2=$res[0][changesqlquote(errordb_errcallbacktext2,"")];
$errtitle=$res[0][changesqlquote(errordb_errtitle,"")];
$errobj=new ta_errorhandle();
$errobj->senderror($errmsg,$custerrcode,$errpriority,$errcallback1,$errcalltext1,$errcallback2,$errcalltext2,$errtitle);
}
如果在master_user.php
(必需文件)中发生异常,则必须将其捕获在需要该文件的文件中。 但这并没有捕获到异常。
我抛出异常的方式:
throw new Exception('#ta@0000000_0000000');
其中的字符串是错误代码。
错误信息:
Fatal error: Uncaught exception 'Exception' with message '#ta@0000000_0000000' in
C:\xampp\htdocs\techahoy\securedir\phpmaster\master_user.php:19 Stack trace: #0
C:\xampp\htdocs\techahoy\login\profile.php(4): ta_userinfo->userinit() #1 {main} thrown in
C:\xampp\htdocs\techahoy\securedir\phpmaster\master_user.php on line 19
看起来(几乎)与此处相同。
require()与include()相同,除了失败时还会产生致命的E_COMPILE_ERROR级错误。 换句话说,它将停止脚本
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.