English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Basic PHP Tutorial

Advanced PHP Tutorial

PHP & MySQL

PHP Reference Manual

PHP user_error() Function Usage and Example

PHP Error & Loggings Reference Manual

user_error() function

Syntax

bool user_error ( string $error_msg [, int $error_type] );

Definition and usage

This function is an alias of trigger_error(), used to trigger user error conditions, and can be used with built-in error handlers or user-defined functions set as new error handlers (set_error_handler()).

Parameter

Serial numberParameters and descriptions
1

error_msg (required)

It specifies the error message. Limited to1024characters.

2

error_types (optional)

It specifies the error type of this error message.

Possible error types-

  • E_USER_ERROR - User-generated fatal runtime errors. Unrecoverable errors. The script execution is paused.

  • E_USER_WARNING - User-generated non-fatal runtime warnings. The script execution will not stop.

  • E_USER_NOTICE - Default. User-generated runtime notifications. The script found content that may be an error, but it may also occur during normal script execution.

Return value

If an incorrect error_type is specified, this function returns FALSE; otherwise, it returns TRUE.

Online Example

The following is the usage of this function-

<?php
    if ($test<10") {
    user_error("The number cannot be less than10");
}
?>

Output result:

The number cannot be less than10

PHP Error & Loggings Reference Manual