iam*_*esy 4 php codeigniter http-headers
我有一个CI应用程序,具有auth控制器和switchuser功能.基本上它只需要从URI获取ID,从ID获取一些用户数据,分配一些会话数据然后加载视图.
function switch_user(){
if(!$this->auth_lib->is_admin()){
$this->session->set_flashdata('status', 'You need to be an administrator to access this page.');
redirect('auth/login');
}
if($id = $this->uri->segment(3)):
$this->load->model('auth_model', 'auth');
$username = $this->auth->get_username($id)->account_name;
$this->session->set_userdata(array('at_id' => $id, 'username' => $username));
$this->session->set_flashdata('status','User switched.');
endif;
$this->load->model('clients_model', 'clients');
$data['users'] = $this->clients->get_at_clients();
$this->load->view('auth/switch', $data);
}
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
Message: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\cp\application\controllers\auth.php:130)
Run Code Online (Sandbox Code Playgroud)
第130行是$ username = $ this-> auth-> get_username($ id) - > account_name;
这是模型功能:
function get_username($at_id){
$portal = $this->load->database('warehouse', TRUE);
$portal->select('account_name');
$portal->where('account_id', $at_id);
$portal->from('wh_account');
$query = $portal->get()->result();
return $query[0];
}
Run Code Online (Sandbox Code Playgroud)
我不明白发生了什么.当我在本地运行代码时,我没有收到错误.但是当我远程运行它时,即通过互联网,我得到了标题错误.
任何人都可以帮助确定问题吗?
谢谢,
比利
UPDATE
我实际上在$ username = $ this-> auth-> get_username($ id) - > account_name周围放了一个var_dump; 导致错误的行.我不知道为什么虽然:(
归档时间: |
|
查看次数: |
15410 次 |
最近记录: |