PHP trigger_error() Function
Complete PHP Error Reference Manual
Definition and Usage
The trigger_error() function creates a user-defined error message.
The trigger_error() function is used to trigger an error message under user-specified conditions. It can be used with the built-in error handler or with a user-defined function set by set_error_handler().
This function is useful when you need to customize an error message under a specified condition while the script is running.
Returns FALSE if an invalid error type is specified, otherwise returns TRUE.
Syntax
trigger_error(error_message,error_types)
| Parameters | Description |
|---|---|
| error_message | Required. Specifies the error message. Limited to 1024 characters in length. |
| error_types | Optional. Specifies the error type of the error message.
Possible error types: |
Example
1)
{
trigger_error("A custom error has been triggered");
}
?>
The output of the code above is shown below:
Notice
: A custom error has been triggered
in
C:webfoldertest.php
on line
6