O
O
Optimus2018-02-15 19:15:32
PHP
Optimus, 2018-02-15 19:15:32

Is it possible to try / catch Fatal error?

There is a code:

try {
        $obj  = new myClass;
    } catch (Exception $e) {
        // обработка
    }

The problem is that the class myClass does not exist and the error Fatal error: Class ... not found in ... So it is not caught by this construction in any way or am I doing something wrong?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
neol, 2018-02-15
@neol

For PHP 7.0 and later

try {
        $obj  = new myClass;
} catch (Throwable $e) {
        // обработка
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question