调用表单助手 CodeIgniter 时出现空白页

Blank page when call form helper CodeIgniter

在我添加表单助手之前,我得到了所有结果并且没有错误。
但是,当我调用表单助手时,我只得到空白页面而没有错误。
控制器脚本:

class Reza extends CI_Controller
 {

  function __construct()
   {
     parent::__construct();
     $this->load->library(array("rez_lib"));
   }
  function index(){
    $this->rez_lib->display("home");
  }
}

库脚本:

class Rez_lib
 {
  protected $_ci;
  function __construct(){
     $this->_ci =& get_instance();
  }
  function display($temp, $data=null){

    $data['header'] = $this->_ci->load->view("construct/header",$data,true);
    $data['sidebar'] = $this->_ci->load-    >view("construct/sidebar",$data,true);
    $data['content']  = $this->_ci->load->view("page/".$temp,$data,true);
    $this->_ci->load->view("construct/all",$data,true);
  }
}

首先出现黑屏是因为您没有启用调试。 转到index.php并在开发时将'ENVIRONMENT'常量设置为'development'。

其次,您的图书馆中似乎有几个拼写错误 class。

  1. 在您的构造函数中,您在 & 和 get_instance() 之间有一个额外的 space:$this->_ci =& get_instance();
  2. 在你的 class 正文中你还有一个额外的 space 在 load- 和 ->view 之间(当加载你的侧边栏时)$data['sidebar'] = $this->_ci->load- >view("construct/sidebar",$data,true);

最后,您将视图作为数据返回,因为第三个参数设置为 true。参见:

There is a third optional parameter lets you change the behavior of the method so that it returns data as a string rather than sending it to your browser. This can be useful if you want to process the data in some way. If you set the parameter to TRUE (boolean) it will return data. The default behavior is false, which sends it to your browser. http://www.codeigniter.com/user_guide/general/views.html