try, catch, finally Are All Optional

<?php

try {
    doSomething();
} catch (Exception $e) {
    processException($e);
} finally {
    cleanupWork();
}

// finally is optional
try {
    doSomething();
} catch (Exception $e) {
    processException($e);
}

// catch is optional
try {
    doSomething();
}

// In the end, catch is also optional
    doSomething();

?>

The finally clause in a try-catch-finally is actually optional: it can be omitted.

The catch clauses in a try-catch-finally are also optional: they can be omitted.

When the catch and finally clauses are all omitted, the try clause can also be omitted safely.

See Also

PHP Features

Last updated: 14 July 2026