Answers for "throw error php"

PHP
0

php catch exception

<?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";
?>
Posted by: Guest on August-03-2020
0

throwable php

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
}
Posted by: Guest on October-17-2021
0

php throw fatal error

trigger_error("Fatal error", E_USER_ERROR);
Posted by: Guest on September-09-2021

Browse Popular Code Answers by Language