Login   Register  
PHP Classes
elePHPant
Icontem

File: example1.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Yasir Siddiqui  >  PHP Exception Logger  >  example1.php  >  Download  
File: example1.php
Role: Example script
Content type: text/plain
Description: Example Script
Class: PHP Exception Logger
Log PHP exceptions to view in BugSense
Author: By
Last change:
Date: 1 year ago
Size: 1,205 bytes
 

Contents

Class file image Download
<?php

include "exceptionlogger.php";
$logger = new ExceptionLogger();

//trigger exception in a "try" block
try
  {
  
checkNumValue(2);
  
//If the exception is thrown, this text will not be shown
  
echo 'No exception occured';
  }

//catch exception
catch(Exception $e)
  {
    
$logger->logException("5.0","Customer Relationship Management System",$e);
  }
  
try {
    
    
///// Try connecting to mysql server a
    
$connected connectToDbServer();
    
    if(
$connected) {
        
        echo 
"Connected with server"
    }
    
    
$connected connectAgain();
    
    if(!
$connected) {
        
        
//// Unable to connect so throw exception
        
        
throw new Exception("Unable to connect to database please try again later");
    }
       
}
catch (
Exception $e) {
    
    
$logger->logException("5.0","Customer Relationship Management System",$e);
}


function 
checkNumValue($number)
  {
  if(
$number<=5)
    {
        throw new 
Exception("Number should be greater than 5");
    }
  return 
true;
  }
  
function 
connectToDbServer() {
    
    return 
true;
}

function 
connectAgain() {
    
    return 
false;
}


?>