I'm trying to run this example #1, from this page: http://php.net/manual/en/language.exceptions.php
getMessage(), "n"; } // Continue execution echo "Hello Worldn"; ?>
However, the output I get is not expected:
0.2 Fatal error: Uncaught exception 'Exception' with message 'Division by zero.' inxxx: 7 Stack trace: #0 xxx(14): inverse(0) #1 {main} thrown in xxx on line 7
The development environments I use are UniServer 3.5
and PHP 5.2.3
I just ran into this exact problem, it feels like I've even copied the name of the exception and it's not catching it. Turns out to be a stupid mistake on my part, but I thought I'd post my situation here in case anyone else is in the same situation.
My exception is calledAin my namespace and the script is calledBin one namespace. The problem is that I have aA\MyExceptionwhich is equal (in PHP) to\B\A\MyException(because my script is calledB# in the namespace ##!). All I had to do was add a backslash (or whatever it was called) before the exception name to fix it so it looked like this:\A\MyException