技术栈

[PHP]empty一直返回true

Balmunc2023-09-08 11:41
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() 会被调用。

上一篇:做项目和做产品的区别
下一篇:uView实现全屏选项卡
相关推荐
0白露
2 天前
关闭搜狗输入法右下角广告,可以适用于大多数应用系统通知的广告
windows·bug
一只自律的鸡
2 天前
【Linux驱动】bug处理 ens33找不到IP
linux·运维·bug
Lichenpar
4 天前
Springboot采用FastJson2作为MessageConverter时,配置的全局日期类型序列化转换BUG
java·开发语言·bug
Irene1991
5 天前
AI 找 bug 的局限性 和 Deepseek 优势明显
bug
癫狂的兔子
5 天前
【bug】【Python】pandas中的DataFrame.to_excel()和ExcelWriter的区别
python·bug
skywalker_11
5 天前
Java中异常
java·开发语言·异常
Fcy648
5 天前
C++ 异常详解
开发语言·c++·异常
癫狂的兔子
6 天前
【BUG】【Python】【Spider】Compound class names are not allowed.
开发语言·python·bug
netkiller-BG7NYT
6 天前
阿里云语音合成CosyVoice重大BUG被我发现了
bug
马猴烧酒.
7 天前
【Mybatis出现bug】应为 <statement> 或 DELIMITER,得到 ‘id‘
java·bug·mybatis
热门推荐
01GitHub 镜像站点02Clawdbot 中文汉化版 接入微信、飞书03OpenCode 入门教程:介绍 · 安装 · 配置第三方 API (如 Claude)04Claude Code Skills 实用使用手册05Claude Code + GLM4.7 避坑指南:解决 Unable to connect to Anthropic services06UV安装并设置国内源07OpenClaw部署与配置教程:在Mac mini上接入国产大模型与飞书08在Trae中使用Pencil MCP092025 年大语言模型发展回顾:关键突破、意外转折与 2026 年展望10Linux下V2Ray安装配置指南