Costruttore di eccezioni PHP
Esempio
<?php
...
throw new Exception("Division by zero", 1);
...
?>
Definizione e utilizzo
Il Exception()
costruttore viene utilizzato per creare un oggetto Exception e impostare alcune delle sue proprietà.
Sintassi
new Exception(message, code, previous)
Valori dei parametri
Parameter | Description |
---|---|
message | Optional. A string describing why the exception was thrown |
code | Optional. An integer that can be used used to easily distinguish this exception from others of the same type |
previous | Optional. If this exception was thrown in a catch block of another exception, it is recommended to pass that exception into this parameter |
Pagine correlate
Maggiori informazioni sulle eccezioni nel nostro capitolo sulle eccezioni PHP .
❮ Riferimento eccezione PHP