当我尝试使用set_error_handler时,Laravel会出现unserialize()错误

in Laravel i'm trying to use php set_error_handler method to handel errors by web application and avoid to crash that, unfortunately when i define this code on __constructor() such as this sample i get this error:

array:4 [▼
"Error no " => 8
"Error String" => "unserialize(): Error at offset 0 of 123 bytes"
"Error File " => "C:\xampp\htdocs\instacheeta\vendor\laravel\framework\src\Illuminate\Auth\Recaller.php" "Error Line" => 24 ]

my code:

public function __construct()
{
    set_error_handler([$this, 'customError'], E_ALL);
    parent::__construct();
}

function customError($errno, $errstr, $errfile, $errline)
{
    dd(
        [
            'Error no ' => $errno,
            'Error String' => $errstr,
            'Error File ' => $errfile,
            'Error Line' => $errline
        ]
    );
}

it seems problem is using arguments on dd, when i commented dd i dont get error

how can i resolve this problem?

There's nothing wrong with what you did. Unfortunately you have set your own error-handler which calls the customError method. obviously i think there really is an error.

DD dumps the given variables and ends execution of the script as stated in the documentation.

so when you deleted the DD line the method customError became empty/void although the captured error is still there.

That is the purpose of using set_error_handler so you could set a user-defined error handler function and decide what to do with the trapped errors.