php__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 -> attribute = 5;
- $a -> attribute;
- ?>
/phprm/859.htmlwww.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之友评论