时间:2021-07-01 10:21:17 帮助过:2人阅读
慢慢长寻夜,明月高空挂
__get() - 读取不可访问属性的值时,__get() 会被调用
__set() - 在给不可访问属性赋值时,__set() 会被调用
'; echo $example->public."\n"; echo $example->protected."\n"; echo $example->private."\n"; echo $example->other."\n"; echo '
'; $example->public = 'lic'; //这个赋值成功所有没有显示 $example->protected = 'tec'; $example->private = 'vat'; $example->other = 'er'; echo '
'; echo '打印 public 属性:'.$example->public;
结果如下:
pub 调用__get()方法:protected 调用__get()方法:private 调用__get()方法:other name:protected,value:tec name:private,value:vat name:other,value:er 打印 public 属性:lic
http://www.bkjia.com/PHPjc/916823.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/916823.htmlTechArticlePHP 魔术方法 __get __set (二),__get__set 慢慢长寻夜,明月高空挂 __get() - 读取不可访问属性的值时, __get() 会被调用 __set() - 在给不可访问属性...