摘要:<?php const IS_ISSET = true; const IS_SET = true; const IS_GET = true; const IS_UNSET = false; class Visit{ protected $data&n
<?php
const IS_ISSET = true;
const IS_SET = true;
const IS_GET = true;
const IS_UNSET = false;
class Visit{
protected $data = [];
public function __isset($name){
return IS_ISSET && isset($this->data[$name]);
}
public function __get($name){
return IS_GET ? $this->data[$name] : '非法访问';
}
public function __set($name,$value){
IS_SET ? $this->data[$name] = $value : '禁止赋值';
}
public function __unset($name){
if(IS_UNSET){
unset($this->data[$name]);
}else{
echo '禁止销毁';
}
}
}
$visit = new Visit();
if(isset($visit->table)){
echo $visit->table,'<br>';
}else{
$visit->table = 'table_staff';
}
echo $visit->table,'<br>';
$visit->table = 'table_foots';
echo $visit->table;
unset($visit->table);
echo $visit->table;
批改老师:查无此人批改时间:2019-07-04 13:20:05
老师总结:完成的不错。基础上php已经入门了,以后多练习实战项目。继续加油。