- <?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()检查属性值
- ?>
- ~