[PHP]empty一直返回true

php 复制代码
class Post
{
    public function __get($key)
    {
        return true;
    }
}

$post = new Post();
var_dump(empty($post->a));// bool(true)

PHP: 重载 - Manual

读取不可访问(protected 或 private)或不存在的属性的值时,__get() 会被调用。

当对不可访问(protected 或 private)或不存在的属性调用 isset()empty() 时,__isset() 会被调用。

相关推荐
Lichenpar1 天前
Springboot采用FastJson2作为MessageConverter时,配置的全局日期类型序列化转换BUG
java·开发语言·bug
Irene19912 天前
AI 找 bug 的局限性 和 Deepseek 优势明显
bug
癫狂的兔子2 天前
【bug】【Python】pandas中的DataFrame.to_excel()和ExcelWriter的区别
python·bug
skywalker_113 天前
Java中异常
java·开发语言·异常
Fcy6483 天前
C++ 异常详解
开发语言·c++·异常
癫狂的兔子3 天前
【BUG】【Python】【Spider】Compound class names are not allowed.
开发语言·python·bug
netkiller-BG7NYT3 天前
阿里云语音合成CosyVoice重大BUG被我发现了
bug
马猴烧酒.4 天前
【Mybatis出现bug】应为 <statement> 或 DELIMITER,得到 ‘id‘
java·bug·mybatis
请叫我大虾4 天前
发现一个jdk中ArrayList的小BUG
android·java·bug
离离茶4 天前
【笔记1-10】Qt bug记录:dockwidget通过raise在最前面显示,toolbar的拓展菜单失效
笔记·qt·bug