PHP trigger_error()Functions
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 together with the built-in error handler, or with a user-defined function set by the set_error_handler() function.
This function is useful when you need to customize an error message under a specified condition while running a script.
If an invalid error type is specified, the function returns FALSE; otherwise, it returns TRUE.
Syntax
trigger_error(error_message,error_types)
| Parameters | Description |
|---|---|
| error_message | Required. Specifies the error message. Length limited to 1024 characters. |
| error_types | Optional. Specifies the error type of the error message. Possible error types:
|
Examples
<?php
$test=2;
if ($test>1)
{
trigger_error("A custom error has been triggered");
}
?>
The output of the above code is shown below:
Notice: A custom error has been triggered
in C:webfoldertest.php on line 6
in C:webfoldertest.php on line 6
Other Extensions