PHP问题与“__ php_incomplete_class” [英] PHP problem with "__php_incomplete_class"

查看:690
本文介绍了PHP问题与“__ php_incomplete_class”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个使用CodeIgniter的网站,并创建了一个用户和一个会话:

  $ user-> first_name ='Gerep'; 
$ user-> gender ='M';
$ user-> age ='26';


$ this-> session-> set_userdata('user',$ user);

但是当我尝试访问会话对象时:

  echo $ this-> session-> userdata('user') - > first_name; 

它返回一个错误:类__PHP_Incomplete_Class的对象无法转换字符串



我一直这样工作,从来没有这个问题。



谢谢!

解决方案

当PHP试图在会话中反序列化对象时,类定义未被加载。

您可以使用自动加载来解决您的问题


I'm developing a website with CodeIgniter and have created a User and a session:

$user->first_name = 'Gerep';
$user->gender = 'M';
$user->age = '26';


$this->session->set_userdata('user', $user);

But when I try to access the session object:

echo $this->session->userdata('user')->first_name;

It returns me a error: Object of class __PHP_Incomplete_Class could not be converted to string

I have always worked like that and never had that problem.

Thanks!

解决方案

The class definition had not been loaded, when PHP tried to deserialize the object in the session.

You can solve your problem by employing Autoloading.

这篇关于PHP问题与“__ php_incomplete_class”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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