Monday, June 28, 2010

PHP Class Constructor

//parent class

class BaseModel
{
    public $table;
    public $db_host;
    public $db_usr;
    public $pw;
    public $db;
   
    public function __construct()
    {
        $this->db_host = "some value";
        $this->db_usr = "some value";
        $this->pw = "some value";
        $this->db = "some value";
    }
}

//child class
class ChildModel extends BaseModel
{
    public function __construct()
    {
        parent::__construct();          
       $this->table = "some value";
    }
}

No comments:

Post a Comment