开发者

How can this object be an object but not an object?

This

if(is_object($value)) echo 'AAA';
if(gettype($value)==='object') echo 'BBB'

Prints 'BBB'.

Specifically开发者_运维技巧, value is __PHP_Incomplete_Class Object which is the result of unserialize. Why would is_object return false though?


From the PHP manual:

Note:

This function will return FALSE if used on an unserialized object where the class definition is not present (even though gettype() returns object).


As AJ was explaining, the object isn't an object because it's incomplete. An object was put into _SESSION then later tried failed to be de-serialized and woken up because the objects class hasn't been defined yet. If you can resolve this by either including the class into scope before starting session's or by using __autoload or spl_autoload_register as a last ditch rescue attempt.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜