PHP多重继承

时间:2014-02-17 14:23:22

标签: php inheritance multiple-inheritance

我尝试从彼此继承多个类,但在某处发生了错误。课程如下:

MobilInterface类的一部分:

class MobileInterface
{

private $config;

private $errorData;

private $data;

private $output;

private $job;

public $dbLink;

public function __construct($config) {
    $this->config = $config;
}

public function initialize($job) {
    $this->dbLink = $this->createDbInstance($this->config);
    require_once 'jobs/' . strtolower($this->config->joblist[$job]) .'.php';
    $this->job = new $this->config->joblist[$job]($this);               
}

public function run($params) {
    $job = $this->job;
    $this->data = $this->job->run($_GET);

}
 }

Mobil Interface是主界面,它根据$ config中的字符串调用Kupon类。我的问题是我想要更多类似Kupon的类,并希望使BaseJob类能够在没有构造函数的情况下编写每个Job类。

问题是Kupon类无法看到$ dbLink和$ config变量。

BaseJob类:

 <?php
class BaseJob
{

public $interface;

public $dbLink;

public $config;

public function __construct(MobileInterface $interface) {
    $this->interface = $interface;
    $this->config = $this->interface->get('config');
    $this->dbLink = $this->interface->get('dbLink');
}

}
?>

和库普班:     

function __construct(){
    parent::__construct(MobileInterface $interface);
}
}
?>

0 个答案:

没有答案