PHP arsort() Function

Example

If $usernum is greater than 10, trigger an error:

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

The output of the above code is similar to this:

Notice: Number cannot be larger than 10
 in C:\webfolder\test.php on line 6

Definition and Usage

The trigger_error() function creates user-level error messages.

The trigger_error() function can be combined with the built-in error handler associated, or a user-defined function can be used as a new error handler (set_error_handler()).

Syntax

trigger_error(errormsg,errortype);
Parameter Description
errormsg Required. Specify the error message. Maximum length 1024 bytes.
errortype

Optional. Specify the error type. Possible values:

  • E_USER_ERROR
  • E_USER_WARNING
  • E_USER_NOTICE (default)

Technical Details

Return value: If an error type is specified errortypeReturns FALSE. Otherwise returns TRUE.
PHP Version: 4.0.1+