In a page try catch, use the A1 of a in the c1,c1 of C using the B1,B1 in B.
The default is: A1 throws an exception, B1 catch the A1 exception, and then throw the exception, C1 capture, and then throw, the last page capture and output.
The result:
x-powered-by:php/5.1.1
Content-type:text/html
#0 D:\workspace\myzCollection\test.php (): A->a1 ()
#1 D:\workspace\myzCollection\test.php (): B->b1 ()
#2 D:\workspace\myzCollection\test.php (Panax): C->c1 ()
#3 C:\Program files\zend\zendstudio-5.2.0\bin\php5\dummy.php (1): Include (' D:\workspace\my ... ')
#4 {Main}end
Second Test:
B1 inside the throw $e removed, is not thrown.
The result:
x-powered-by:php/5.1.1
Content-type:text/html
End
A third Test:
Put the B1 inside the throw new Exception ($e->getmessage ());
Throws a new exception so that the A1 exception is not b1 to the call above.
The result:
x-powered-by:php/5.1.1
Content-type:text/html
#0 D:\workspace\myzCollection\test.php (): B->b1 ()
#1 D:\workspace\myzCollection\test.php (Panax): C->c1 ()
#2 C:\Program files\zend\zendstudio-5.2.0\bin\php5\dummy.php (1): Include (' D:\workspace\my ... ')
#3 {Main}end
A fourth Test:
Remove the try catch throw in the B1.
Result: Everything is normal, that is, the Middle step does not need to throw, the top can also get the lowest level of the exception thrown.
There is only one problem, b if the first exception, there is no way to, if you need to also detect B, then also in B to add a try Catch
x-powered-by:php/5.1.1
Content-type:text/html
#0 D:\workspace\myzCollection\test.php (): A->a1 ()
#1 D:\workspace\myzCollection\test.php (): B->b1 ()
#2 D:\workspace\myzCollection\test.php (Panax): C->c1 ()
#3 C:\Program files\zend\zendstudio-5.2.0\bin\php5\dummy.php (1): Include (' D:\workspace\my ... ')
#4 {Main}end
<?php
Class A {public
function A1 () {
try {
throw new Exception (' 123 ');
\ catch (Exception $e) { C6/>throw $e;
}
}} Class B {public
function B1 () {
try {
$a = new A ();
$a->a1 ();
} catch (Exception $e) {
throw $e;
throw new Exception ($e->getmessage ());
}} Class C {public
function C1 () {
try {
$a = new B ();
$a->b1 ();
} catch (Exception $e) {
throw $e;
}
}} try {
$c = new C ();
$c->c1 ();
} catch (Exception $e) {
echo $e->gettraceasstring ();
}
echo 789;
? >