问题描述
在我的XAMPP / Win XP构建中,PHP5.2.3无法捕获任何异常。 都不起作用,而且:
On my XAMPP/Win XP build, PHP5.2.3 fails to catch any exceptions. None of the examples work, and this:
try {
throw new Exception('Fail');
} catch (Exception $e) {
echo 'Succeed';
}
...结果:
所有PHP的错误设置似乎都是标准的。服务器为Apache / 2.2.4
All of PHP's error settings seem standard. Server is Apache/2.2.4
推荐答案
这取决于XAMPP中 eAccelerator的版本。在某一时刻,它有,而忽略了它们。
This depends on eAccelerator's build in XAMPP. At one point, it had trouble optimizing try/catch statements and just ignored them.
问题出在0.9.5。 XAMPP当前与eAccelerator 0.9.5.3捆绑在一起,尽管默认情况下它已禁用。因此,这可能不是您的问题。
The problem was in 0.9.5. XAMPP currently is bundled with eAccelerator 0.9.5.3, although it is disabled by default. So this might not be your issue.
根据,XAMPP在很长一段时间内都没有使用过PHP 5.2.3和Apache 2.2.4,这也是eAccelerator错误发生的时间。我建议检查您的eAccelerator版本,并可能升级XAMPP。
According to the ChangeLog, XAMPP hasn't used PHP 5.2.3 and Apache 2.2.4 in a LONG time, which is also around the time of the eAccelerator bug. I recommend checking your eAccelerator version and possibly upgrading XAMPP.
这篇关于PHP5:为什么try / catch失败?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!