无法将类stdClass的对象转换为字符串 [英] Object of class stdClass could not be converted to string

查看:987
本文介绍了无法将类stdClass的对象转换为字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在有一个问题,我得到这个错误,

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

此行正在调用此函数,

   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 c>函数返回一个对象,而不是一个字符串。查看文档(或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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆