我有这些模特:
class Content_model extends MY_Model{
public function __construct()
{
$test='main_content';
parent::__construct($test);
}
}
class MY_Model extends CI_Model {
public function __construct($recived_parameter) {
parent::__construct ();
// do something with $recived_parameter
}
}
我想将参数$test
传递给MY_Model的构造,但似乎没有任何东西被收回。有什么想法吗?
答案 0 :(得分:1)
class Content_model extends CI_Model{
protected $param = "Haloo";
public function __construct()
{
parent::__construct();
}
}
class MY_Model extends Content_model {
public function __construct() {
echo $this->param;
}
}