南墙 @Ta | |
2021-01-23 22:06 |
class Preson{
public $name; //定义变量
public $age;
public $sex;
public $height;
}
$Preson1 = new Preson();
$Preson1->$name = "大白"; //变量赋值
$Preson1->$age = 20;
$Preson1->$sex = "女";
$Preson1->$height = 180;
class Preson{
public $name; //定义变量
public $age;
public $sex;
public $height;
function __construct($name,$age,$sex,$height){
$this->name = $name; //为变量赋值
$this->age = $age;
$this->sex = $sex;
$this->height = $height;
}
public function PlayBaskteBall(){
if($this->height>175 || $this->age < 22){
return $this->name . "可以打篮球";
}else{
return $this->name . "不具备打球的条件";
}
}
}
$Preson1 = new Preson("大白","20","女","180");
echo $$Preson1->PlayBaskteBall();
阅:1576 | 发表于2021-01-23 22:06 |
心灵鸡汤:
      
®2019-2024 all power by Zlproject3.7
川公网安备 51192202000151号
蜀ICP备2021014921号-2
首页 #top
天合之作 曲在人意