Easy Tutorial
❮ Func Array Sum Func String Chunk Split ❯

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 the set_error_handler() function.

If an invalid error type is specified, the function returns FALSE, otherwise it returns TRUE.

Syntax

Parameter Description
error_message Required. Specifies the error message. The length is limited to 1024 characters.
error_types Optional. Specifies the error type for the error message. Possible error types: E_USER_ERROR - User-generated runtime fatal error. Unrecoverable error. Stops script execution. <br> E_USER_WARNING - User-generated runtime non-fatal warning. Script execution does not stop. <br> E_USER_NOTICE - Default. User-generated runtime notice. The script found something that could be an error, but may also occur during normal script execution.

Example

<?php
$test = 2;
if ($test > 1)
{
    trigger_error("A custom error has been triggered");
}
?>

The output of the above code is as follows:


Complete PHP Error Reference Manual

❮ Func Array Sum Func String Chunk Split ❯