Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/286.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP多重继承_Php_Inheritance_Multiple Inheritance - Fatal编程技术网

PHP多重继承

PHP多重继承,php,inheritance,multiple-inheritance,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

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

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接口是主接口,它根据$config中的字符串调用Kupon类。我的问题是,我想要更多类似Kupon的类,并且想要创建一个BaseJob类,以便能够在不使用构造函数的情况下编写每个作业类

问题是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');
}

}
?>

接口的目的不是要有函数签名,实现它们的类应该实现这些函数吗?拥有一个名为接口的类是一种巨大的、腐朽的代码气味。另外,PHP不支持多重继承(尽管我在你的问题中没有看到这样的例子),我只想创建一个BaseJob类,为Kupon类分配所有变量,我将有多个Kupon类,它们是“jobs”。我知道了,函数uu构造($interface){//var_dump($interface);parent::_construct($interface)}我需要构造函数参数中的$interface。如果您找到了解决方案,请创建一个答案并接受它。
function __construct(){
    parent::__construct(MobileInterface $interface);
}
}
?>