随机codeigniter错误“刷新页面时无法修改标题信息 - 已发送的标题”

时间:2013-04-20 17:25:31

标签: php codeigniter session http-headers codeigniter-2

我已经在这里阅读了六个类似的问题,并且已经仔细检查过我的库中<?php之前或?>之前没有空格。

好的,请注意我收到此错误 RANDOMLY 。当我在页面上并多次按CTRL + R(刷新)时,对于类似2或3次连续尝试,错误消息不存在,然后出现错误消息并继续多次尝试..

我得到的确切错误消息是

<h4>A PHP Error was encountered</h4>

<p>Severity: Warning</p>
<p>Message:  Cannot modify header information - headers already sent by (output started at A:\work\fast\semi 6\software engineering\project\project2\main\repo\main_proj\application\config\admin_template.php:2)</p>
<p>Filename: libraries/Session.php</p>
<p>Line Number: 672</p>

显然,罪魁祸首似乎是admin_template.php库文件..

调用库的控制器函数:

 public function view_items(){
    $this->session->set_userdata('f');
    $table="F";
    $this->admin_template->display_direct($table,'');
    }

我在这里复制文件

请注意<?php位于第1行

<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Admin_template{

    private
    $selected_item=-1,

    $menu=
        array(
        'Items'=>
            array(
              'Add Item'=>'admin/items/add_item',
              'View Items'=>'admin/items/view_items',

            ),
        'Administration'=>
            array(
                'View Admins'=>'admin/administration/view_admins',
                'View Representatives'=>'admin/administration/view_representative'
            )
        );


    public function __construct(){
    foreach($this->menu as $key=>$items){
        $this->menu[$key]['size']=sizeof($items);
    }
    $this->ci=&get_instance();
    }

    public function display_direct($view){
    $admin_template_data=array();
    $admin_template_data['content']=$view;
    $admin_template_data['heading']="heading";
    $admin_template_data['menu']=$this->menu;
    $admin_template_data['selected_item']=1;//$this->get_selected_item();

    return $this->ci->load->view('admin/main_template',$admin_template_data);
    }


}

0 个答案:

没有答案