Eccezione PHP metodo getPrevious()
Esempio
Ottieni informazioni su un'eccezione precedente:
<?php
try {
try {
throw new Exception("An
error occurred", 1);
} catch(Exception $e1) {
throw new Exception("Another error occurred", 2, $e1);
}
}
catch (Exception $e2) {
echo $previous = $e2->getPrevious();
echo $previous->getMessage();
}
?>
Definizione e utilizzo
Se l'eccezione è stata attivata da un'altra eccezione, il getPrevious()
metodo restituisce l'altra eccezione. Altrimenti restituisce null.
Sintassi
$exception->getPrevious()
Dettagli tecnici
Valore di ritorno: | Restituisce un numero intero |
---|
Pagine correlate
Maggiori informazioni sulle eccezioni nel nostro capitolo sulle eccezioni PHP .
❮ Riferimento eccezione PHP