xref: /PHP-5.6/Zend/tests/catch_finally_004.phpt (revision 60a29791)
1--TEST--
2Try catch finally (nesting try-catch-finally)
3--FILE--
4<?php
5
6function throw_exception($msg) {
7    throw new Exception($msg);
8}
9
10function foo (&$ex) {
11   try {
12      echo "1";
13      try {
14        echo "2";
15        throw_exception("try");
16      } catch (Exception $e) {
17        echo "3";
18        throw_exception("catch");
19      } finally {
20        echo "4";
21        throw_exception("finally");
22      }
23   } catch (Exception $e) {
24      $ex = $e;
25      echo "3";
26   } finally {
27      echo "2";
28   }
29   return 1;
30}
31
32var_dump(foo($ex));
33
34do {
35  var_dump($ex->getMessage());
36} while ($ex = $ex->getPrevious());
37?>
38--EXPECT--
39123432int(1)
40string(7) "finally"
41string(5) "catch"
42