[英]Dynamic PHP Variables not working with codeigniter php view file using mPDF
//code in my controller
//get users data
$users = $this->users->get_users();
$data['users'] = $users;
//fetch view fro pdf_output.php view file
$html=$this->load->view('pdf_output', $data,TRUE);
//load mPDF library
$this->load->library('m_pdf');
//write content using pdf library
$this->pdf->WriteHTML($html);
$this->pdf->Output($pdfFilePath, "I");
//code in my view file
print_r($data);exit;
I am unable to access the $data variable in "pdf_output.php" view file in codeigniter 3.0. 我无法在codeigniter 3.0中的“ pdf_output.php”视图文件中访问$ data变量。 I am getting an error like "Message: Undefined variable: data".
我收到类似“消息:未定义的变量:数据”的错误。
Please post the answer if anyone have. 如果有人,请发布答案。
In your view file the variable will be $users instead of $data. 在您的视图文件中,变量将是$ users而不是$ data。
if you have an array like this for example 例如,如果您有一个像这样的数组
$data['users'] = array("user1","user2");
$this->load->view('viewpage', $data);
in your view file it will be $users; 在您的视图文件中将是$ users;
print_r($users);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.