Login   Register  
PHP Classes
elePHPant
Icontem

File: magicobject.cls.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Duy A. Nguyen  >  Small MySQL Connection  >  magicobject.cls.php  >  Download  
File: magicobject.cls.php
Role: Application script
Content type: text/plain
Description: sample abstract class
Class: Small MySQL Connection
MySQL database access wrapper
Author: By
Last change:
Date: 8 years ago
Size: 1,187 bytes
 

Contents

Class file image Download
<?php
class MagicObject
{
    protected 
$data = array();

     public function 
__get($property_name)
    {
        
        if (isset(
$this->data[$property_name])) 
            return 
$this->data[$property_name];

        
trigger_error("Getting unavailable property <b>$property_name</b>!"E_USER_ERROR);

        return 
null;
    }

    public function 
__set($property_name$val)
    {

        if (isset(
$this->data[$property_name])) 
            
$this->data[$property_name] = $val;
        else
            
trigger_error("Setting unvailable property <b>$property_name</b>!"E_USER_ERROR);
        
    }

    public function 
__isset($property_name)
    {
        return isset(
$this->data[$property_name]);
    }

    public function 
__unset($property_name)
    {
        unset(
$this->data[$property_name]);
    }
    
    public function 
toString()
    {
          return 
var_export($thistrue);
    }
    
    public function 
__call($function_name$function_args null)
    {
        if( empty(
$function_name) )
            return 
null;
        if( empty(
$function_args) )
            return 
$this->function_name();
        return 
$this->function_name($function_args);
    }

    
    
}
?>