类 stdClass 的对象无法转换为字符串 [英] Object of class stdClass could not be converted to string
问题描述
我目前在使用 PHP 时遇到问题,出现此错误,
I am having a problem with PHP at the moment, I am getting this error,
类 stdClass 的对象无法转换为字符串
在我的站点中运行这部分代码时发生错误,
Object of class stdClass could not be converted to string
the error occurs when I run this portion of code in my site,
function myaccount() {
$data['user_data'] = $this->auth->get_userdata($this->uri->segment(3));
//var_dump($data['user_data']);
$this->load->model('users_model');
$data['user_info'] = $this->users_model->get_user_and_roadmaps_by_id($this->uri->segment(3));
$this->template->build('users/my_account', $data);
}
发生错误的行是这一行,
The line in which the error is occuring is this one,
$data['user_data'] = $this->auth->get_userdata($this->uri->segment(3));
而这一行正在调用这个函数,
And this line is calling this function,
function get_userdata() {
$CI =& get_instance();
if(!$this->logged_in()) {
return false;
} else {
$query = $CI->db->get_where('users', array('user_id' => $CI->session->userdata('user_id')));
return $query->row();
}
}
我现在真的不知道这个问题是什么,所以任何帮助都会很棒.
I don't really now what this problem is, so any help would be great.
推荐答案
很可能,userdata()
函数返回的是一个对象,而不是一个字符串.查看文档(或 var_dump 返回值)以找出您需要使用的值.
Most likely, the userdata()
function is returning an object, not a string. Look into the documentation (or var_dump the return value) to find out which value you need to use.
这篇关于类 stdClass 的对象无法转换为字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!