1--TEST--
2Exceptions before fatal error
3--FILE--
4<?php
5function exception_error_handler($code, $msg) {
6    throw new Exception($msg);
7}
8
9set_error_handler("exception_error_handler");
10
11try {
12    $foo->a();
13} catch(Exception $e) {
14    var_dump($e->getMessage());
15}
16
17try {
18    new $foo();
19} catch(Exception $e) {
20    var_dump($e->getMessage());
21}
22
23try {
24    throw $foo;
25} catch(Exception $e) {
26    var_dump($e->getMessage());
27}
28
29try {
30    $foo();
31} catch(Exception $e) {
32    var_dump($e->getMessage());
33}
34
35try {
36    $foo::b();
37} catch(Exception $e) {
38    var_dump($e->getMessage());
39}
40
41
42try {
43    $b = clone $foo;
44} catch(Exception $e) {
45    var_dump($e->getMessage());
46}
47
48class b {
49}
50
51try {
52    b::$foo();
53} catch(Exception $e) {
54    var_dump($e->getMessage());
55}
56?>
57--EXPECT--
58string(23) "Undefined variable: foo"
59string(23) "Undefined variable: foo"
60string(23) "Undefined variable: foo"
61string(23) "Undefined variable: foo"
62string(23) "Undefined variable: foo"
63string(23) "Undefined variable: foo"
64string(23) "Undefined variable: foo"
65