subclass and super method

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
pgarcia
Forum Newbie
Posts: 1
Joined: Sat Aug 09, 2008 3:04 pm

subclass and super method

Post by pgarcia »

Hi...

I have the class MasterDomain then I need to creat an extends class from this. But my HlmDomain class doesn't take the variable of its parent class. How could implement the 'super()' method or something similar in php?

Thanks

Code: Select all

   
class MasterDomain {
 
    private $_dockey = "";
    
    private $_renewal_dockey = "";
    
    private $_promotion;
    
    public static $_giftformname = "form1";
    
    private $_new_subscriber = array ();
    
    private $_magabbr = '';
    
    private $_gift;
    
    private $_transaction;
    
    private $_universalID;
    
    private $_single_account;
    
    private $_discount_flag = "";
    
    private $container;
    
    private $_default_term_renewal = 5;
    
    private $_process = NULL;
 
    
    public function MasterDomain($dockey = "", $promotion = "", $magabbr = '', $renewaldockey="") {
 
        $this->_dockey          = $dockey;
        
        $this->_promotion       = $promotion;
        
        $this->_renewal_dockey  = $renewaldockey;
        
        $this->_magabbr         = $magabbr;
        
        $this->_gifts           = new Gifts();
        
        $this->_transaction     = new Transaction();
        
        $this->_single_account  = new Account();
        
        $this->container = new Container();
        
    }
}
 
class HlmDomain extends MasterDomain {
 
    public function HlmDomain($dockey = "", $promotion = "", $magabbr = 'hlm', $renewaldockey="") {
 
        $this->_dockey          = $dockey;
 
        $this->_promotion       = $promotion;
        
        $this->_renewal_dockey  = $renewaldockey;
        
        $this->_magabbr         = $magabbr;
        
        $this->_gifts           = new Gifts();
        
        $this->_transaction     = new Transaction();
        
        $this->_single_account  = new Account();
        
        $this->container = new Container();
        
    }
    
}
        
 
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: subclass and super method

Post by Christopher »

Declare the properties in the base class as protected, not private. See the manual for a full description of private, protected and public.
(#10850)
Post Reply