views:

414

answers:

2

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

+4  A: 

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.

St. John Johnson
Thanks. Will upgrade and see how it goes...
mrclay
Fixed, though even the current XAMPP had an incompatible eAccelerator.dll. I replaced with "eAccelerator0953_5.2.8.dll" and all works.
mrclay
A: 

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

Scott Evernden