Construtor de Exceções PHP
Exemplo
<?php
...
throw new Exception("Division by zero", 1);
...
?>
Definição e uso
O Exception()
construtor é usado para criar um objeto Exception e definir algumas de suas propriedades.
Sintaxe
new Exception(message, code, previous)
Valores de parâmetro
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 |
Páginas relacionadas
Leia mais sobre Exceções em nosso Capítulo de Exceções do PHP .
❮ Referência de exceção PHP