Hello,
class User
{
private $_var_1 = 10;
private $_var_2 = 20;
private function _preExecute() {
//do something here before executing sub-class's method
}
private function _postExecute() {
//do something here after executing sub-class's method
}
private function _anyMethod() {
echo "Hello!";
}
public function execute($action) {
$this->_preExecute();
$obj = new __CLASS__."_".$action;
$obj->execute();
$this->_postExecute();
}
}
class User_Add
{
public function execute() {
echo $this->_var1;
echo $this->_var2;
parent::_anyMethod();
}
}
$user = new User();
$user->execute("Add");
So, as you can see I want to be able to access User class's variables and methods from class User_Add, is it possible in PHP 5.2 or higher?
Thank you.