PHP user_error()Function
Complete PHP Error Reference Manual
Definition and Usage
The user_error() function creates a user-defined error message.
The user_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 the set_error_handler() function.
This function is useful when you need to customize an error message under certain specified conditions while running a script.
If an invalid error type is specified, the function returns FALSE; otherwise, it returns TRUE.
This function is trigger_error()an alias of the function.
Syntax
user_error(error_message,error_types)
| Parameter | Description |
|---|---|
| error_message | Required. Specifies the error message. The length limit is 1024 characters. |
| error_types | Optional. Specifies the error type of the error message. Possible error types:
|
Examples
<?php
$test=2;
if ($test>1)
{
user_error("A custom error has been triggered");
}
?>
$test=2;
if ($test>1)
{
user_error("A custom error has been triggered");
}
?>
The output of the above code is as follows:
Notice: A custom error has been triggered
in C:webfoldertest.php on line 6
in C:webfoldertest.php on line 6
Complete PHP Error Reference Manual Other Extensions