我的admin.php控制器中有这样的东西:
function __construct()
{
parent::__construct();
if (!$this->session->userdata('logged_in_admin') )
{
redirect('admin/login');
}
$this->load->model('mdl_admin');
$data['my_test_variable'] = "This is test!";
}
public function index()
{
$data['header'] = "Home";
$this->load->view('admin_frontpage', $data);
}
在我看来:
<?php echo $header; ?>
<?php echo $my_test_variable; ?>
但只有标头变量被回显。即使发送到视图文件的 $data 数组也包含my_test_variable。
这是为什么?
我究竟做错了什么?
即使我尝试例如:
$this->data['my_test_variable'] = "This is test!";
它不工作。