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%
- 相关评论
- 我要评论
-