gpt4 book ai didi

php - Codeigniter: header 已发送错误

转载 作者:塔克拉玛干 更新时间:2023-11-03 06:06:55 26 4
gpt4 key购买 nike

<分区>

我有一个 CI 应用程序,它具有 auth Controller 和 switchuser 功能。基本上它所做的一切都是从 URI 中获取一个 ID,从该 ID 中获取一些用户数据,分配一些 session 数据,然后加载一个 View 。

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);
}

我收到以下错误:

Message: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\cp\application\controllers\auth.php:130)

第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];
}

我不明白发生了什么。当我在本地运行代码时,我没有收到错误。但是当我远程运行它时,即通过互联网运行时,我得到了标题错误。

谁能帮忙找出问题所在?

谢谢,

比利

更新

我实际上在 $username = $this->auth->get_username($id)->account_name; 周围放了一个 var_dump; 导致错误的行。虽然我不知道为什么:(

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com