在我添加表单助手之前,我得到了所有结果并且没有错误。 但是,当我调用表单助手时,我只是得到空白页而没有错误。 控制器脚本:
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'。
其次,你的图书馆类似乎有几个错别字。
$this->_ci =& get_instance();
$data['sidebar'] = $this->_ci->load- >view("construct/sidebar",$data,true);
最后,您将视图作为数据返回,因为第三个参数设置为true。看到:
第三个可选参数允许您更改方法的行为,以便它将数据作为字符串返回,而不是将其发送到您的浏览器。如果要以某种方式处理数据,这可能很有用。如果将参数设置为TRUE(布尔值),它将返回数据。默认行为为false,将其发送到您的浏览器。 http://www.codeigniter.com/user_guide/general/views.html