PHP set_exception_handler() İşlevi
Örnek
Kullanıcı tanımlı bir istisna işleyici işlevi ayarlayın:
<?php
// A user-defined exception handler function
function myException($exception)
{
echo "<b>Exception:</b> ", $exception->getMessage();
}
// Set user-defined exception handler function
set_exception_handler("myException");
// Throw exception
throw new Exception("Uncaught exception occurred!");
?>
Tanım ve Kullanım
set_exception_handler() işlevi, kullanıcı tanımlı bir özel durum işleyici işlevi ayarlar.
İstisna işleyici çağrıldıktan sonra komut dosyası yürütmeyi durduracaktır.
Sözdizimi
set_exception_handler(exceptionhandler);
Parametre Değerleri
Parameter | Description |
---|---|
exceptionhandler | Required. Specifies the name of the function to be run when an uncaught exception occurs. NULL can be passed instead, to reset this handler to its default state |
Teknik detaylar
Geri dönüş değeri: | Önceden tanımlanmış istisna işleyicisini veya hata durumunda NULL veya daha önce hiçbir işleyici tanımlanmamışsa içeren bir dize |
---|---|
PHP Sürümü: | 5.0+ |
PHP Değişiklik Günlüğü: | Önceden, NULL iletildiyse, bu işlev DOĞRU döndürdü. PHP 5.5'ten beri önceki işleyiciyi döndürür |
PHP Hata Referansı