<?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->i = 0;
 
    }
 
    
 
    /**                                        
 
     * The Class Destructor                            
 
     *                                        
 
     */
 
    public function __destruct()
 
    {
 
        $this->errors = null;
 
        $this->i = 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);
 
?>
 
 |