Recover သို့meaningful translate လုပ်နိုင်သောboundary မှာသာfailure ကိုcatch လုပ်ပါ။
ပိုပြီးနားလည်ထားရမယ့် အချက်
Throwable hierarchy, warnings/notices, exceptions နဲ့fatal failures ကိုlogging/user-response policy ဖြင့်ခွဲပါ။ Specific failures catch လုပ်၊cause/context ထိန်းပြီးglobal boundary မှာsafe response ပြန်ပါ။
လက်တွေ့မှာ ဘယ်လိုအသုံးချမလဲ
Exceptions & Error Handling example ကိုnormal, boundary, invalid နဲ့failure inputs ဖြင့်run/test လုပ်ပြီး output, warnings, exceptions နဲ့side effects ကိုမှတ်တမ်းတင်ပါ။
ဒီသင်ခန်းစာပြီးရင်
<?php
declare(strict_types=1);
function divide(float $a, float $b): float {
if ($b == 0.0) throw new InvalidArgumentException('zero divisor');
return $a / $b;
}
try { echo divide(10, 2); } catch (InvalidArgumentException $e) {
error_log($e->getMessage()); echo 'Invalid calculation';
}5ကိုယ်တိုင်စမ်းကြည့်ရန်
Exceptions & Error Handling example ကိုnormal, boundary, invalid နဲ့failure inputs ဖြင့်run/test လုပ်ပြီး output, warnings, exceptions နဲ့side effects ကိုမှတ်တမ်းတင်ပါ။
Security/Common Mistake သတိပေးချက်
Production response ထဲstack trace သို့secrets ပြခြင်းကအရေးကြီးအချက်အလက်ပေါက်ကြားစေပါတယ်။
PHP Language Reference — PHP Documentation Group