PHP essayer le mot-clé
Exemple
Utilisez une instruction try...catch pour gérer les exceptions :
<?php
try {
throw new Exception("This is an exception");
}
catch(Exception $e) {
echo $e->getMessage();
}
?>
Définition et utilisation
Le try
mot clé est utilisé pour créer un try...catch
, ou une try...catch...finally
instruction.
Pages connexes
Le throw
mot clé.
Le catch
mot clé.
Le finally
mot clé.
En savoir plus sur try..catch.finally (Exceptions) dans notre tutoriel PHP Exceptions .
❮ Mots clés PHP