PHP Classes

File: test.php

Recommend this page to a friend!
  Classes of Indrek Altpere   Simple error handling class   test.php   Download  
File: test.php
Role: Example script
Content type: text/plain
Description: testing example
Class: Simple error handling class
Intercept and log PHP execution errors
Author: By
Last change: Added few example lines how to use SetDieLevel function and a dummy class that has static and non-static functions to display the usage of setting class methods to be called instead of global functions
Date: 16 years ago
Size: 895 bytes
 

Contents

Class file image Download
<?php
require_once 'ErrorManager.php';

function
die0() {
  echo
'died in global function';
}

class
Call {
  public static function
die1() {
    echo
'died in static function';
  }
  public function
die2() {
    echo
'died in class function';
  }
}
ErrorManager::SetLogFile('error.log');
ErrorManager::SetLogLevel(E_ALL | E_STRICT, true);
ErrorManager::SetDebug(true, false);//echo debug data and do it between <pre></pre> tags
//different correct implementation of SetDieLevel
//remove or modify exiting levels to let the script execute beyond first error
ErrorManager::SetDieLevel(E_WARNING, 'die0');
//ErrorManager::SetDieLevel(E_WARNING, array('Call', 'die1'));
//ErrorManager::SetDieLevel(E_WARNING, array(new Call(), 'die2'));
echo 'going to do 1/0 ';
$a = 1 / 0;
echo
'going to do incorrect function call for str_replace ';
$b = str_replace('test', 'test');
?>