w3schools    w3Schools
Search :
   
HOME HTML CSS XML JAVASCRIPT ASP PHP SQL MORE...   References Examples Forum About
ADVERTISEMENTS

XML Certification
Download XML editor
Custom Programming
 
Table of contents
PHP Basic
PHP HOME
PHP Intro
PHP Install
PHP Syntax
PHP Variables
PHP String
PHP Operators
PHP If...Else
PHP Switch
PHP Arrays
PHP Looping
PHP Functions
PHP Forms
PHP $_GET
PHP $_POST

PHP Advanced
PHP Date
PHP Include
PHP File
PHP File Upload
PHP Cookies
PHP Sessions
PHP E-mail
PHP Secure E-mail
PHP Error
PHP Exception
PHP Filter

PHP Database
MySQL Introduction
MySQL Connect
MySQL Create
MySQL Insert
MySQL Select
MySQL Where
MySQL Order By
MySQL Update
MySQL Delete
PHP ODBC

PHP XML
XML Expat Parser
XML DOM
XML SimpleXML

PHP and AJAX
AJAX Introduction
XMLHttpRequest
AJAX Suggest
AJAX XML
AJAX Database
AJAX responseXML
AJAX Live Search
AJAX RSS Reader
AJAX Poll

PHP Reference
PHP Array
PHP Calendar
PHP Date
PHP Directory
PHP Error
PHP Filesystem
PHP Filter
PHP FTP
PHP HTTP
PHP Libxml
PHP Mail
PHP Math
PHP Misc
PHP MySQL
PHP SimpleXML
PHP String
PHP XML
PHP Zip

PHP Quiz
PHP Quiz
PHP Exam

Selected Reading
Web Statistics
Web Glossary
Web Hosting
Web Quality

Browse Tutorials
 

PHP user_error() Function


PHP Error Reference Complete PHP Error Reference

Definition and Usage

The user_error() function creates a user-defined error message.

The user_error() function is used to trigger an error message at a user-specified condition. It can be used with the built-in error handler, or with a user defined function set by the set_error_handler() function.

This function is useful when you need a user-defined message to a specified condition when running a script runtime.

This function returns FALSE if a non valid error type is specified, and TRUE otherwise.

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

Syntax

user_error(error_message,error_types)
 
Parameter Description
error_message Required. Specifies the error message. Limited to 1024 characters in length
error_types Optional. Specifies the error type for this error message.

Possible error types:

  • E_USER_ERROR - Fatal user-generated run-time error. Errors that can not be recovered from. Execution of the script is halted
  • E_USER_WARNING - Non-fatal user-generated 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 happen when running a script normally


Example

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

The output of the code above should be something like this:

Notice: A custom error has been triggered
in C:\webfolder\test.php on line 6
 
PHP Error Reference Complete PHP Error Reference