[英]Catchable fatal error: Object of class __PHP_Incomplete_Class
i get this error 我得到这个错误
Catchable fatal error: Object of class __PHP_Incomplete_Class could not be converted to string in user.php on line 248 this is the line 可捕获的致命错误:无法在第248行的user.php中将类__PHP_Incomplete_Class的对象转换为字符串。
function loadUser($userID)
{
global $db;
$res = $db->getrow("SELECT * FROM `{$this->dbTable}` WHERE `{$this->tbFields['userID']}` = '".$this->escape($userID)."' LIMIT 1");
if ( !$res )
return false;
$this->userData = $res;
$this->userID = $userID;
$_SESSION[$this->sessionVariable] = $this->userID;
return true;
}
see 看到
var_dump($_SESSION);
array(1) { ["user"]=> &object(__PHP_Incomplete_Class)#1 (12) { ["__PHP_Incomplete_Class_Name"]=> string(11) "jooria_user" ["dbTable"]=> string(5) "users" ["sessionVariable"]=> string(4) "user" } }
Is this an object stored in session? 这是存储在会话中的对象吗? Have you declared your class before retrieving the object from session? 在从会话中检索对象之前,您是否声明过类?
In any case, my guess is that you're missing a class declaration somewhere. 无论如何,我的猜测是您在某处缺少类声明。
EDIT: Your class jooria_user
is not declared before use. 编辑:您的类jooria_user
在使用前未声明。 That is why you get that error. 这就是为什么您会收到该错误。
Say you have this: 说你有这个:
<?php
session_start();
class A {}
$a = new A;
$_SESSION['A'] = $a;
Then you try to access it in this script: 然后尝试在此脚本中访问它:
<?php
session_start();
$a = $_SESSION['A'];
var_dump($a);
/* outputs:
object(__PHP_Incomplete_Class)#1 (1) {
["__PHP_Incomplete_Class_Name"]=>
string(1) "A"
}
*/
Now if you do that instead: 现在,如果您改为这样做:
<?php
class A {} // declares the class here
session_start();
$a = $_SESSION['A'];
var_dump($a);
/* outputs:
object(A)#1 (1) {
}
*/
Looks like the provided function-argument $userID
is an object and the error occurs here: 看起来提供的功能参数$userID
是一个对象,并且在这里发生错误:
$this->escape($userID)
(I don't see any further string-operations that could force such an error). (我看不到任何进一步的字符串操作可能会导致这种错误)。
So check out what's the argument you call loadUser()
with. 因此,请检查您使用loadUser()
调用的参数是什么。
First I'd make sure all { }
braces have pairs in the right place. 首先,我要确保所有{ }
括号在正确的位置都有对。 A }
missing from the last line would be my guess. 最后一行缺少}
是我的猜测。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.