Correcting teacher:PHPz
Correction status:qualified
Teacher's comments:
// include
// 相对路径
include 'inc/hello.php';
// 绝对路径
include __DIR__ . '/inc/hello.php';
echo $username;
// require
// 当路径不存在,代码出错后直接退出
require __DIR__ . 'inc/hello1.php';
echo $username;
class Stu{
public $username;
private $age = 18;
static $tel;
public function __construct($username, $age, $tel)
{
$this ->username = $username;
$this ->age = $age;
$this ->tel = $tel;
}
public function __get($age)
{
if($age === 'age'){
return $this ->$age + 5;
}
}
public function __set($age, $value)
{
if($age === 'age'){
if($value >=18 && $value <=30){
$this ->$age =$value;
} else{
echo '你超龄了';
}
}
}
}
$user = new Stu('小李', 19, 13632801080);
echo $user ->age, '<br>';
$user->age = 48;