Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

try, catch, finally sont tous optionnels

<?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();

?>

La clause finally dans un try-catch-finally est en fait optionnelle : elle peut être omise.

Les clauses catch dans un try-catch-finally sont également optionnelles : elles peuvent être omises.

Lorsque les clauses catch et finally sont toutes omises, la clause try peut également être omise en toute sécurité.

See Also

PHP Features

Last updated: 11 October 2026