php - Proper way to access parent's methods in child class -


i have childclass extends parentclass. parentclass has constructor takes 2 arguments __construct('value2', parentclass::common). trying call inherited newselect() method within child class. far has not been succesfull. how call newselect() childclass? possible though parentclass has constructor takes 2 parameters?

parent

class parentclass {      const common = 'common';  protected $db;  protected $common = false;  protected $quotes = array( 'common' => array('"', '"'), 'value2' => array('`', '`'), 'value3' => array('`', '`'), 'value4' => array('`', '`'), );  protected $quote_name_prefix;  protected $quote_name_suffix;     public function __construct($db, $common = null) {     $this->db = ucfirst(strtolower($db));     $this->common = ($common === self::common);     $this->quote_name_prefix = $this->quotes[$this->db][0];     $this->quote_name_suffix = $this->quotes[$this->db][1];    }   public function newselect() {     return $this->newinstance('select');  }   protected function newinstance($query) {     //some more code,  not relevant example  }   } 

child

class childclass extends parentclass {            public function __construct() {      }      // call inherited method      private $_select = parent::newselect();      //  } 

// can't this

private $_select = parent::newselect(); 

// try this

private $_select;  public function construct($value, $common) {     parent::__construct($value, $common);     $this->_select = $this->newselect(); } 

// and

$obj = new childclass('value2', parentclass::common); //  parentclass::common - not sure why $select = $obj->newselect(); // being called in constructor, why call again 

and honest, don't know you're trying looks wrong too!


Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -