php中,用try/catch捕获了异常,为什么还会有警告?有没有办法去掉呢?
代码:try{preg_match_all($pattern,$string,$all);}catch(Exception$ex){echo$ex->getTraceAs...
代码:
try
{
preg_match_all($pattern,$string,$all);
}
catch (Exception $ex)
{
echo $ex->getTraceAsString();
}
错误提示:
Warning: preg_match_all() [function.preg-match-all]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'UTC' for '8.0/no DST' instead in F:\php\doom\newfile.php on line 52
Warning: preg_match_all() [function.preg-match-all]: Empty regular expression in F:\php\doom\newfile.php on line 52
能否说明下“@抑制错误”的具体语法呢 展开
try
{
preg_match_all($pattern,$string,$all);
}
catch (Exception $ex)
{
echo $ex->getTraceAsString();
}
错误提示:
Warning: preg_match_all() [function.preg-match-all]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'UTC' for '8.0/no DST' instead in F:\php\doom\newfile.php on line 52
Warning: preg_match_all() [function.preg-match-all]: Empty regular expression in F:\php\doom\newfile.php on line 52
能否说明下“@抑制错误”的具体语法呢 展开
4个回答
展开全部
因为它既抛出异常又触发错误, 你需要@抑制错误, try并不负责屏蔽错误触发, 只负责接收抛出的异常
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
php 不提供内置抛出异常,如果用try catch 必须自定义异常,并且手动throws才可以!
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
试试把error_reporting(0);这句放在php文件的开头
至于@
则是在函数前加 如
while ($row = @mysql_fetch_assoc($qrt))
至于@
则是在函数前加 如
while ($row = @mysql_fetch_assoc($qrt))
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
我也想来看看结果到底是咋样的。来学习了。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询