这个物体怎么可能是物体而不是物体呢?
这
if(is_object($value)) echo 'AAA';
if(gettype($value)==='object') echo 'BBB'
将打印“BBB”。
具体来说,值为__PHP_Incomplete_Class Object
,它是unserialize
的结果。为什么 is_object
会返回 false?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
来自 PHP 手册:
From the PHP manual:
正如 AJ 所解释的,该对象不是对象,因为它不完整。一个对象被放入_SESSION,然后尝试反序列化和唤醒失败,因为对象类尚未定义。如果您可以通过在启动会话之前将类包含到范围中或使用 __autoload 或 spl_autoload_register 作为最后的救援尝试来解决此问题。
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.