C'è un modo per dire a PHP di generare un'eccezione quando sto tentando di accedere a un membro o un metodo su un oggetto null
?PHP gestisce la gestione nulla in base all'eccezione
Es .:
$x = null;
$x->foo = 5; // Null field access
$x->bar(); // Null method call
In questo momento, ho solo i seguenti errori che non sono bello da gestire:
PHP Notice: Trying to get property of non-object in ...
PHP Warning: Creating default object from empty value in ...
PHP Fatal error: Call to undefined method stdClass::bar() in ...
Vorrei avere una deroga specifica invece essere gettato. È possibile?
Registrare un [gestore errori globale] (http://php.net/manual/en/function.set-error-handler.php) e lanciare le proprie eccezioni. – Rob