Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

PHP user_error() Function

PHP user_error() Function


PHP Error Reference Manual 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 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.

This function is an alias of the trigger_error() function.

Syntax

user_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:

  • E_USER_ERROR - User-generated fatal run-time error. Cannot be recovered from. Execution of the script is halted.
  • E_USER_WARNING - User-generated non-fatal run-time warning. Execution of the script is not halted.
  • E_USER_NOTICE - Default. User-generated run-time notice. The script found something that might be an error, but could also occur during normal script execution.
  • |

    Example

    1) { user_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


    PHP Error Reference Manual Complete PHP Error Reference Manual