PHP头条
热点:

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;//__set()设置属性值
$a -> attribute; //__get()检查属性值

 

www.phpzy.comtrue/php/29252.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 - attribute = 5;//_...

相关文章

    暂无相关文章

PHP之友评论

今天推荐