如何覆盖属性?

时间:2019-07-22 06:26:00

标签: php codeigniter properties

所以我想在类的codeigniter项目中使用一个属性,但不能覆盖它。

这是我的代码:

class DateDisplay extends CI_Controller{

      public $mydate = '2019-01-01';

      public function index(){
        $data['date'] = $this->mydate;

        $this->load->view('templates/header');
        $this->load->view('date_view', $data);
        $this->load->view('templates/footer');
      }

      public function new_date(){
        $this->mydate = $this->input->post('new_date');
        redirect('datedisplay');
      }
}

在调用new_date函数之后,我想设置一个新日期,并使用该新日期数据加载视图,但是它不起作用。如果我echo $this->mydate看到了新日期,但是在重定向之后,它将被基本日期2019-01-01覆盖

0 个答案:

没有答案