Question : php catch exception
Answered by : fynn
<?php
function inverse($x) {
if (!$x) {
throw new Exception('Division durch Null.');
}
return 1/$x;
}
try {
echo inverse(5) . "\n";
echo inverse(0) . "\n";
} catch (Exception $e) {
echo 'Exception abgefangen: ', $e->getMessage(), "\n";
}
// Ausführung fortsetzen
echo "Hallo Welt\n";
?>
Source : https://www.php.net/manual/de/language.exceptions.php | Last Update : Mon, 10 Aug 20
Question : php catch fatal error
Answered by : prickly-pelican-qyue18pu42yp
try { do some thing evil
} catch (Error $e) { echo 'Now you can catch me!';
}
Source : https://stackoverflow.com/questions/12928487/php-try-catch-and-fatal-error?rq=1 | Last Update : Mon, 15 Jun 20