PHP trigger_error() Function

P
PHP chroot() Function
PHP set_exception_handler() Function

In this article, you learn how to define a human-readable error message for any error handling function in PHP.

The trigger_error() function in PHP creates a user-level error message. The trigger_error() function can be used with the built-in error handler, or with a user-defined function set by the set_error_handler() function.

what is the syntax of the TRIGGER_ERROR() function in php?

trigger_error(message, type)
ParameterDescription
messageRequired. Specifies the error message for this error. Max 1024 bytes in length
typeOptional. Specifies the error type for this error. Possible values:E_USER_ERRORE_USER_WARNINGE_USER_NOTICE (this is default)
PHP TRIGGER_ERROR() method

examples of the TRIGGER_ERROR() function

Example 1. In this example, we if $usernum > 10, trigger an error.

<?php
if ($usernum>10) {
    trigger_error("Number cannot be larger than 10");
}
?>
PHP chroot() Function
PHP set_exception_handler() Function

Add comment

Tutor Network

Share this

Learn PHP from A to Z