PHP hata ve istisna arasındaki bazı farklar nelerdir?

0 Cevap

PHP bir acemi değilim. Şimdiye kadar, kaynağından bir istisna tetiklemek için tek mekanizma, öğrenme yaşıyorum atar bir satır yazma gereğidir.

throw new Exception('message')

Ayrıca, aşağıdaki kodu, herhangi bir istisna atılır olmayacak, ancak bir hata artırılacaktır.

try
{
    $file = fopen('no such file.txt', 'r');
}
catch(Exception $e)
{
    echo 'Exception: ' . $e->getMessage();
}

Please give me some explanations. It seems this try..catch block is not so useful in PHP, unlike in Java or .NET.

0 Cevap