我的控制器代码是
路径:application / views / admin
控制器代码
public function email()
{
$data['page'] = lang('settings');
$data['load_setting'] = 'email_settings';
$data['title'] = lang('email_settings'); //Page title
$data['subview'] = $this->load->view('admin/settings/settings', $data, TRUE);
$this->load->view('admin/_layout_main', $data); //page load
$qry = $this->db->query("SELECT * FROM `tbl_email_setting` WHERE user_id='".$this->session->userdata('user_id')."'");
$data1['email_values'] = $qry->result_array();
$this->load->view('admin/settings/email_settings', $data1);
}
我在视图中将$data1
传递给email_settings.php
个文件。
当我尝试在$email_values
中打印views/admin/settings/email_settings.php
时,错误将在下面显示
遇到PHP错误 严重性:注意 消息:未定义的变量:email_values 文件名:settings / email_settings.php 行号:109
答案 0 :(得分:1)
根据您的意见:
这是我打印的视图代码<?php echo 'email server type:-----';print_r($data1['email_values']);?>
- R V Informatics Pvt Ltd
您只需将视图文件中的数据打印为:
<?php
echo 'email server type:-----';
print_r($email_values);
?>
建议/附注:
我建议您将此视图存储在变量中:
$this->load->view('admin/_layout_main', $data); //page load
同样如此:
$data['subview'] = $this->load->view('admin/settings/settings', $data, TRUE);