【发布时间】:2022-01-21 02:40:07
【问题描述】:
请问如何解决这个问题? 它给了我问题错误
当前类作用域没有父级时无法访问父级::
我不知道我能做什么,请帮忙
class MY_Controller
{
public function __construct()
{
parent::__construct();
$this->load->driver("cache", ["adapter" => "apc", "backup" => "file", "key_prefix" => "vie_"]);
$this->data = [];
$this->data["settings"] = $this->m_core->getSettings();
$this->config->load("config", true);
if (md5("" . get_domain_host(base_url())) != $this->config->item(base64_decode("="), "config")) {
exit(base64_decode(""));
}
$this->data["csrf_name"] = $this->security->get_csrf_token_name();
$this->data["csrf_hash"] = $this->security->get_csrf_hash();
}
}
【问题讨论】:
-
你无法访问
parent::...,因为没有父类,所以停止尝试访问不存在的父类 -
请你帮我编辑这段代码
-
没有任何代码试图访问
parent::...或让这个类从另一个类扩展 -
是的,我有```class Page extends MY_Controller { public function index() { $this->data['all_pages'] = $this->m_page->get_all_pages(); $this->data['page'] = '所有页面'; $this->load->view('user_template/pages', $this->data); } public function proof() { $this->data['page'] = 'Payment Proofs'; $this->db->order_by('id', "desc")->limit(20); $this->data['proofs'] = $this->db->get('withdraw_history')->result_array(); $this->load->view('user_template/proof', $this->data); }
-
请不要在评论区添加修改,而是在您的原帖中添加,谢谢!
标签: php codeigniter