Question : try catch php
Answered by : ivn-javier-londoo-rueda
function inverso($x) { if (!$x) { throw new Exception('Zero division.'); } return 1/$x;
}
try { echo inverso(5) . "\n"; echo inverso(0) . "\n";
} catch (Exception $e) { echo 'and the error is: ', $e->getMessage(), "\n";
}
Source : | Last Update : Sun, 20 Dec 20
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 throw fatal error
Answered by : defiant-dogfish-zklto5nrtn1u
trigger_error("Fatal error", E_USER_ERROR);
Source : | Last Update : Thu, 16 Sep 21