PhpDig.net

What is PhpDig?
PhpDig is a PHP MySQL based
Web Spider & Search Engine.




trigger_error

Name

trigger_error — Triggers an error.

Synopsis

bool trigger_error(error_message[, error_type]);
string error_message: Error message to display/log
int error_type (optional): Type of error to throw

Returns

TRUE if the error could be generated; FALSE if the error_type argument is not a defined E_USER_* error type

Description

trigger_error() is used to generate errors of the E_USER_ERROR, E_USER_WARNING, and E_USER_NOTICE type. Errors of this level can be caught by the built-in PHP error handler or can be handled by a custom error handler. See set_error_handler() for more details on custom error handlers.

Note

To use a custom error handler for errors

set_error_handler()

Version

PHP Version: 4.0.1+

Example

Example 274. Basic use of trigger_error()

# Call trigger_error()
trigger_error ('Error message', E_USER_WARNING);

Example 275. Override PHP's built-in error handler

<?php

$file = 'somefile.txt';

# Suppress any errors for the fopen(...) expression
$fp = @ fopen ($file, 'r');

# If $fp contains FALSE then fopen could not access the file
if (FALSE === $fp) {
    trigger_error ("$file could not be opened.");
}

?>



PHP Functions Essential Reference. Copyright © 2002 by New Riders Publishing (Authors: Zak Greant, Graeme Merrall, Torben Wilson, Brett Michlitsch). This material may be distributed only subject to the terms and conditions set forth in the Open Publication License, v1.0 or later (the latest version is presently available at http://www.opencontent.org/openpub/). The authors of this book have elected not to choose any options under the OPL. This online book was obtained from http://www.fooassociates.com/phpfer/ and is designed to provide information about the PHP programming language, focusing on PHP version 4.0.4 for the most part. The information is provided on an as-is basis, and no warranty or fitness is implied. All persons and entities shall have neither liability nor responsibility to any person or entity with respect to any loss or damage arising from the information contained in this book.

Powered by: vBulletin Version 3.0.7
Copyright ©2000 - 2005, Jelsoft Enterprises Ltd.
Copyright © 2001 - 2005, ThinkDing LLC. All Rights Reserved.