PHP trigger_error () function
Definition and Usage
trigger_error () function to create user-defined error message.
trigger_error () function is used to trigger an error message in the user-specified conditions. It can be used with the built-in error handler, or with the user by the set_error_handler () function is used with the custom setting function.
When you need a custom error message under certain conditions specified when running the script, the function is useful.
If you specify an invalid type of error, the function returns FALSE, otherwise it returns TRUE.
grammar
trigger_error(error_message,error_types)
参数 | 描述 |
---|---|
error_message | 必需。规定错误消息。长度限制为 1024 个字符。 |
error_types | 可选。规定错误消息的错误类型。 可能的错误类型:
|
Examples
<?php
$test=2;
if ($test>1)
{
trigger_error("A custom error has been triggered");
}
?>
$test=2;
if ($test>1)
{
trigger_error("A custom error has been triggered");
}
?>
The output of the code above is as follows:
Notice: A custom error has been triggered
inC:webfoldertest.phpon line6
inC:webfoldertest.phpon line6
Complete PHP Error Reference