throw¶
Throw is the keyword which raise an exception.
When an exception is thrown, the normal flow of the program is interrupted, and PHP starts looking for an exception handler to catch and handle the exception.
<?php
try{
throw new Exception('Error');
} catch (\Exception $e) {
print 'Warning : error was identified!';
}
?>
See also Exceptions - PHP Advance
Related : Try-catch, Exception, ArgumentCountError, ArithmeticError Error, Error, Chaining Exceptions, mysqli_sql_exception, PHP Predefined Exception