好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

php __get(),__set()函数来实现对属性的访问 - php面向

php __get(),__set()函数来实现对属性的访问

<?php  class  class_name  {     var   $attribute ;     function  __get( $name )    {      return   $this  ->  $name ;    }     function  __set( $name , $value )    {       $this  ->  $name  =  $value ;    }  }  $a  =  new  class_name();  $a  -> attribute = 5; //__set()设置属性值   $a  -> attribute;  //__get()检查属性值   ?> 

查看更多关于php __get(),__set()函数来实现对属性的访问 - php面向的详细内容...

  阅读:50次