我在控制器文件中有以下代码,用于检查post varible pdf并执行以下代码
if(isset($_POST['pdf']) && $_POST['pdf']=="pdf") { $this->load->model('voutput_model'); $final_view = $data['frmReport']; $PDF_Name = "report.pdf"; $this->votput_model->pdf($PDF_Name,$final_view); }
class Voutput_model extends CI_Model{ public function __construct() { parent::__construct(); $this->CI = get_instance(); } public function pdf($file_name,$filecontents){ $this->pdf_path = $this->config->item('pdf_path'); $this->load->library('htmltopdf/Html2fpdf'); $file['Attach_path'] = $this->pdf_path.$file_name; $this->html2fpdf->generate_pdf($file['Attach_path'],$filecontents,'Y'); } }
Severity: Notice Message: Undefined property: Voutput::$Voutput_model Filename: controllers/voutput.PHP Fatal error: Call to a member function pdf() on a non-object in C:\xampp\htdocs\asset\application\controllers\voutput.PHP
您需要在使用前加载模型.尝试这个
$this->load->model('votput_model'); $this->votput_model->pdf($PDF_Name,$final_view);