我目前正在这样做,
class Page {
// variable to hold DBC class
public $dbc;
/*
__CONSTRUCT
Called when class is initiated and sets the dbc variable to hold the DBC class.
*/
public function __construct() {
// set the dbc variable to hold the DBC class
$this -> dbc = new DBC();
}
/*
CREATE PAGE
Create a page with the option to pass data into it.
*/
public function create($title, $class, $data = false) {
// start buffer
ob_start('gz_handler');
// content
content($this -> dbc, $data);
// end buffer and flush
ob_end_flush();
}
}
我已经简化了示例,但基本上我需要将对象传递DBC
给方法内的函数create
?
这是否像我以前使用的那样被认为是不好的做法,extends
但意识到无法将扩展类提取到变量中?
谢谢