Login   Register  
PHP Classes
elePHPant
Icontem

File: Example

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Merianos Nikos  >  error_manager  >  Example  >  Download  
File: Example
Role: Example script
Content type: text/plain
Description: This is a sort example
Class: error_manager
Keep track of multiple application errors
Author: By
Last change:
Date: 7 years ago
Size: 1,703 bytes
 

Contents

Class file image Download
<?php
define
('E_1000','This is an error in my application');
define('E_1201','This is another error');

/**                                            
 *  Very Simple Error Managment Class                        
 *                                            
 */
class error_manager
{
    
/**                                        
     * This array keep all the errors till you want to print out the errors    
     *                                        
     * @var Array                                
     */
    
private $errors = array();
    
/**                                        
     * Used as counter to showing the next array position            
     *                                        
     * @var integer                                
     */
    
private $i 0;
    
    
/**                                        
     * The Class Constructor                            
     *                                        
     */
    
public function __construct()
    {
        
$this->errors null;
        
$this->0;
    }
    
    
/**                                        
     * The Class Destructor                            
     *                                        
     */
    
public function __destruct()
    {
        
$this->errors null;
        
$this->0;
    }
    
    
/**                                        
     * Using this method you adding errors in the $errors array to print out    
     * later                                        
     *                                        
     * @param String $error                            
     */
    
public function add_error($error)
    {
        
$this->errors[$this->i] = $error;
        
$this->i++;
    }
    
    
/**                                        
     * Print out all the errors from the $errors array                
     *                                        
     */
    
public function error_print()
    {
        foreach(
$this->errors as $Val)
        {
            echo 
$Val "<br />";
        }
    }
    
    
/**                                        
     * Return the ammount of errors added to the array $errors        
     *                                        
     * @return Integer                                
     */
    
public function error_count()
    {
        return 
sizeof($this->errors);
    }
}

$error = new error_manager();
$error->add_error('You have not access in this area');
$error->add_error(E_1201);
$error->add_error('You have a syntax error');
$error->add_error(E_1000);
?>