批改状态:合格
老师批语:
// 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;
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号