PHP Classes
Icontem

File: example.php


  Search   All class groups All class groups   Latest entries Latest entries   Top 10 charts Top 10 charts   Newsletter Newsletter   Blog Blog   Forums Forums   Help FAQ Help FAQ  
  Login   Register  
Recommend this page to a friend! ReTweet ReTweet Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Pulni4kiya  >  Exceptions Manager  >  example.php  
File: example.php
Role: Example script
Content type: text/plain
Description: An example of all the functions of the class
Class: Exceptions Manager
Throw exceptions depending on a trigger level
 

Contents

Class file image Download
<?
//Instanciate the class
//The first argument is a number between 0 and 15. It's the max level at which an exception would be thrown.
//The second argument is a boolean. It allows you to change the exceptions level after instanciation if set to true.
$exM = new ExceptionsManager(ExceptionsManager::EX_MEDIUMfalse);
//The main idea is to use the class constants for the first value, but you could also use any int between 0 and 15.

//To throw an exception use:
$exM->ThrowException(new Exception('Error'), ExceptionsManager::EX_HIGH); //This one will be thrown: EX_HIGH<EX_MEDIUM
$exM->ThrowException(new Exception('Another Error'), ExceptionsManager::EX_MEDIUM+1); //This one won't be thrown: EX_MEDIUM+1>EX_MEDIUM

//To change the max exceptions level use:
if ($exM->CanChangeExceptionsLevel()) { //checks whether you can change the exceptions level
    
$exM->ChangeExceptionsLevel(ExceptionsManager::EX_FATAL); //changes the exceptions level
}
//$exM->ChangeExceptionsLevel will throw an exception if the class is instanciated with the second argument false

//To get the current exceptions level use:
$a $exM->GetExceptionsLevel();

//To check whether a certian level exception will be thrown
$b $exM->WillThrowException(10); //returns bool

//Note: EX_FATAL is ALWAYS thrown!
?>

 
  Advertise on this site Advertise on this site   Site map Site map   Statistics Statistics   Site tips Site tips   Privacy policy Privacy policy   Contact Contact  

For more information send a message to :
info at phpclasses dot org.
Copyright (c) Icontem 1999-2009 PHP Classes - PHP Class Scripts
  PHP Book Reviews - Reviews of books and other products