Errors vs exceptions in PHP
Në shqip: Gabimet dhe përjashtimet në PHP
ShpjegimiSQ
PHP-ja ka „errors“ (paralajmërime, njoftime) dhe „exceptions“. Që nga PHP 7, shumë gabime fatale janë Error që kapen me catch (Throwable $e). Në prodhim, display_errors duhet të jetë off.
EnglishEN
PHP has “errors” (warnings, notices) and “exceptions”. Since PHP 7, many fatal errors are Error objects you can catch with catch (Throwable $e). In production, display_errors must be off.
Si ta mendosh
Si dallimi mes një drite paralajmëruese dhe një alarmi zjarri.
Lexoje në anglisht
Like the difference between a warning light and a fire alarm.
Shembull kodiphp
try {
$rezultati = intdiv(10, 0);
} catch (DivisionByZeroError $e) {
error_log($e->getMessage());
}