PHP try catch all exceptions
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";
}try
{
// Some code...
}
catch(AError | BError $e)
{
// Handle exceptions
}
catch(Exception $e)
{
// Handle the general case
}<?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";
?>
Also in PHP:
- all error in pp
- database seeding laravel
- console log php variable
- display php error
- check string variable length php
- How to Log Query in Laravel
- check if text is in string php
- decode base 64 php
- check what type variable it is php
- find data format in php
- artisan show routes
- array sort unique laravel
- check if key exists in array php
- artisan laravel command create project
- date time php
- convert image to base64 php
- error e all php
- check if strlen more than 10 laravel
- base64 decode encode online php
- convert time() to date php
- current URL without url site laravel
- ->with()->where laravel
- Class 'App\Http\Controllers\Admin\Route' not found
- downloading php latest version for ubuntu 20.04 using terminal