PHP头条
热点:

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


  1. class class_name 
  2.   var $attribute
  3.   function __get($name
  4.   { 
  5.    return $this -> $name
  6.   } 
  7.   function __set($name,$value
  8.   { 
  9.     $this -> $name = $value
  10.   } 
  11. $a = new class_name(); 
  12. $a -> attribute = 5;//__set()设置属性值 
  13. $a -> attribute; //__get()检查属性值 
  14. ?> 

www.phpzy.comtrue/phprm/859.htmlTechArticlephp__get(),__set()函数来实现对属性的访问 class class_name { var $attribute ; function __get( $name ) { return $this -> $name ; } function __set( $name , $value ) { $this -> $name = $value ; } } $a = new class_name(); $a ->attribu...

相关文章

相关频道:

PHP之友评论

今天推荐