Page 1 of 1

subclass and super method

Posted: Sat Aug 09, 2008 3:12 pm
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();
        
    }
    
}
        
 

Re: subclass and super method

Posted: Sat Aug 09, 2008 4:34 pm
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.