主页 > php易尔灵网络科技

php 属性魔术方法

256 2024-03-11 06:53

php class Example { private $data = []; public function __get($name) { if (array_key_exists($name, $this->data)) { return $this->data[$name]; } return null; } } $example = new Example(); $example->name = 'Alice'; echo $example->name; // Output: Alice echo $example->age; // Output: null
顶一下
(0)
0%
踩一下
(0)
0%
相关评论
我要评论
点击我更换图片

热点提要

网站地图 (共30个专题169867篇文章)

返回首页