Question

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';
}

...results in:

Fatal error: Uncaught exception 'Exception' with message 'Fail' in M:\path\to\test.php:4 Stack trace: #0 {main} thrown in M:\path\to\test.php on line 4

All of PHP's error settings seem standard. Server is Apache/2.2.4

Was it helpful?

Solution

This depends on eAccelerator's build in XAMPP. At one point, it had trouble optimizing try/catch statements and just ignored them.

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.

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.

OTHER TIPS

I get "Succeed" as output running your script, both standalone on command line and via apache on a webserver as well as in XAMPPLITE. Dunno what's different from your setup

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top