<?php class MyClassException extends Exception { public function __construct(string $message, public string $className = '') { parent::__construct($message); } } spl_autoload_register(static function ($className) { // Do magic class file loading here. throw new MyClassException('Class not found', $className); }); try { $a = unserialize('O:10:"DummyClass":0:{}'); } catch (MyClassException $e) { $a = null; // Or some other missing class handling } var_dump($a);
You have javascript disabled. You will not be able to edit any code.