“php jetable” Réponses codées

php jetable

try {
// Code that may throw an Exception or Error.
} catch (Throwable $t) {
// Executed only in PHP 7, will not match in PHP 5.x
} catch (Exception $e) {
// Executed only in PHP 5.x, will not be reached in PHP 7
}
Lucky Llama

php thorwable vs exception


Throwable does not work on PHP 5.x.

To catch both exceptions and errors in PHP 5.x and 7, add a catch block for Exception AFTER catching Throwable first.
Once PHP 5.x support is no longer needed, the block catching Exception can be removed.

try
{
   // Code that may throw an Exception or Error.
}
catch (Throwable $t)
{
   // Executed only in PHP 7, will not match in PHP 5
}
catch (Exception $e)
{
   // Executed only in PHP 5, will not be reached in PHP 7
}
0xC0DE:CAFE

Réponses similaires à “php jetable”

Questions similaires à “php jetable”

Plus de réponses similaires à “php jetable” dans PHP

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code