批改状态:合格
老师批语:完成的不错,继续加油。作业最好写点自己看法和总结。
<?php// 类是命名空间namespace user;// 创建一个类class lists {//成员public $name = '李四';public $age = 36;//方法function getPeople() {$f = new self();return '姓名:'.$f->name .'<br>'.'年龄:'.$f->age;}}// 实例化类$people = new lists();// 输出值echo $people->getPeople();
// 创建一个类class lists {//成员// 属性public $name;public $age;// 构造方法public function __construct($name, $age){$this->name = $name;$this->age = $age;}//方法function getPeople() {return '姓名:'.$this->name .'<br>'.'年龄:'.$this->age;}}// 实例化类$people = new lists('李四',36);// 输出值echo $people->getPeople();

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号