You can catch both exceptions and errors by catching(Throwable)PHP 7'de hataların PHP tarafından bildirilişi değişmiştir. PHP5'te kullanılan geleneksel hata bildirme mekanizması üzerinden bildirmek yerine hataların çoğu Error istisnası yavrulanarak bildirilir.
  Normal istisnalardaki gibi bu Error istisnaları da
  catch
  bloğuyla ilk eşleşmeye kadar kaynamaya devam eder. Eşleşecek blok yoksa,
  set_exception_handler() ile kurulmuş öntanımlı
  işleyicilerden herhangi biri çağrılır, öntanımlı bir istisna işleyicisi yoksa
  istisna ölümcül hataya dönüştürülüp geleneksel bir hata gibi işlem görür.
 
  Error hiyerarşisi Exception
  sınıfından miras almadığından, PHP 5'te yakalanmayan istisnaları işleyecek
  catch (Exception $e) { ... } bloklarını kullanan kod, bu
  hataların (Error) bu bloklarca yakalanmadığını
  bulacaktır. Ya bir catch (Error $e) { ... } bloğu ya da bir
  set_exception_handler() işleyicisi gerekir.
 
You can catch both exceptions and errors by catching(Throwable)Throwable does not work on PHP 5.x.
To catch both exceptions and errors in PHP 5.x and 7, add a catch block for Exception AFTER catching Throwable first.
Once PHP 5.x support is no longer needed, the block catching Exception can be removed.
try
{
   // Code that may throw an Exception or Error.
}
catch (Throwable $t)
{
   // Executed only in PHP 7, will not match in PHP 5
}
catch (Exception $e)
{
   // Executed only in PHP 5, will not be reached in PHP 7
}An excellent blog post on the difference between exceptions, throwables and how PHP 7 handles these can be found here: https://trowski.com/2015/06/24/throwable-exceptions-and-errors-in-php7/php 7.1
try {
   // Code that may throw an Exception or ArithmeticError.
} catch (ArithmeticError | Exception $e) {
   // pass
}<?php
set_error_handler(function(int $number, string $message) {
   echo "Handler captured error $number: '$message'" . PHP_EOL  ;
});
try {
    echo $x; # notice, handled on callable
    pg_exec(null, null); # warning, handled on callable
    fho(); # fatal error, stop running and catched
} catch (Throwable $e) {
    echo "Captured Throwable: " . $e->getMessage() . PHP_EOL;
}
?>
set_error_handler will also works without try and catch