PHP - uitsondering getPrevious() Metode
Voorbeeld
Kry inligting oor 'n vorige uitsondering:
<?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();
}
?>
Definisie en gebruik
As die uitsondering deur 'n ander een veroorsaak is, gee die getPrevious()
metode die ander uitsondering terug. Andersins gee dit nul terug.
Sintaksis
$exception->getPrevious()
Tegniese besonderhede
Terugkeerwaarde: | Wys 'n heelgetal |
---|
Verwante bladsye
Lees meer oor Uitsonderings in ons PHP Uitsonderings Hoofstuk .
❮ PHP-uitsonderingsverwysing