您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

php 的简单存在 (魔术方法作用之一:容错)_PHP教程

2024/3/3 10:22:56发布11次查看
php 的简单存在 (魔术方法作用之一:容错) name =$name; $this->age =$age; } //获取魔术方法 # @param string $name public function __get($param){ // return $this->$param; #允许被访问的属性 $allow = array('age'); if(in_array($param, $allow)){ return $this->$param; } } //__set() 设置魔术方法 #@param string $name #param string $val public function __set($name,$val){ $allow = array('age','money'); if(in_array($name, $allow)){ $this->$name=$val; } } // __isset() 判定数据 public function __isset($name){ return isset($this->$name); } //__unset 销毁数据 public function __unset($name){ //建立unset列表 $allow =array('tail'); if(in_array($name,$allow)){ echo 'unset running'; unset($this->$name); } }}//实例化$p = new person('zp',21);$p->age = 200;echo $p->money = 200000000;$p->tail =a;var_dump(isset($p->name));var_dump(isset($p->age));var_dump(isset($money));// var_dump(empty($tail));unset($p->tail);// var_dump($tail);
http://www.bkjia.com/phpjc/969599.htmlwww.bkjia.comtruehttp://www.bkjia.com/phpjc/969599.htmltecharticlephp 的简单存在 (魔术方法作用之一:容错) name =$name;$this->age =$age;}//获取魔术方法# @param string $namepublic function __get($param){// return $this->$p...
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product