Correcting teacher:查无此人
Correction status:qualified
Teacher's comments:完成的不错,继续加油。写作业,最好能加上自己的看法或总结。
<?php
//命名空间
namespace my\name;
//创建类
class a{
public $name = '张三';
public $age =18;
public function get(){
echo $this->name . '在吃饭';
}
}
//实例化类:
$obj= new \my\name\a;
$obj->get();
<?php
// 成员变量、成员方法
class spObj{
public $name;
public $height;
public $avo;
public function bootFootBall($name,$height,$avo){
$this->name=$name;
$this->height=$height;
$this->avo=$avo;
if($this->height<185 and $this->avo <85){
return $this->name .';符合踢足球的要求!';
}else{
return $this->name .';不符合踢足球的要求!';
}
}
}
$obj=new spObj();
echo $obj->bootFootBall('张三','185','80');
<?php
// 构造方法
class spObj{
public $name;
public $height;
public function __construct($name,$height){
$this->name=$name;
$this->height=$height;
}
public function shuchu(){
echo $this->name . '的身高是' . $this->height ;
}
}
$spObj=new spObj('张三','185');
$spObj->shuchu();