PHP Classes

File: example.php

Recommend this page to a friend!
  Classes of Radovan Janjic  >  PHP Error Handling  >  example.php  >  Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Example script
Class: PHP Error Handling
Log fatal and non-fatal PHP errors
Author: By
Last change:
Date: 2 years ago
Size: 1,019 bytes


Class file image Download

include 'ErrorHandler.class.php';

// Init Error Handler

// Report all errors except E_NOTICE
//ErrorHandler::Init(E_ALL ^ E_NOTICE);

// Report simple running errors
//ErrorHandler::Init(E_ERROR | E_WARNING | E_PARSE);

// Display Errors
ErrorHandler::$displayErrors = TRUE;

// Log file path
// ErrorHandler::Init(E_ALL, 'error.log');
ErrorHandler::$logFile = 'error.log';

// Trigger user errors
//trigger_error('Testing E_USER_WARNING.', E_USER_WARNING);
//trigger_error('Testing E_USER_NOTICE.', E_USER_NOTICE);
//trigger_error('Testing E_USER_ERROR.', E_USER_ERROR);

// Notice

// Mail on E_USER_ERROR
ErrorHandler::$mailOnErrorType = E_USER_ERROR; // any type of error eg E_ALL
ErrorHandler::$mail = '';
ErrorHandler::$mailSub = 'Critical E_USER_ERROR foo bar baz qux.';

// This error will send email now
trigger_error('Testing E_USER_WARNING with mail.', E_USER_WARNING);

// Fatal error