定义成员变量,类中的变量(PHP基础教程)
- <?php
- class sportObject{
- public $name; //定义成员变量
- public $height; //定义成员变量
- public $avoirdupois; //定义成员变量
-
- public function bootFootBall($name,$height,$avoirdupois){ //声明成员方法
- $this->name = $name;
- $this->height = $height;
- $this->avoirdupois = $avoirdupois;
- if($this->height > 20 && $this->avoirdupois <100){
- return $this->name.'符合自丢网招聘要求。';
- }else{
- return $this->name.'不符合自丢网招聘要求。';
- }
- }
- }
- $sport = new sportOBject;
- echo $sport->bootFootBall('小红','80','60');
复制代码 PHP源码输出结果图:
定义成员变量,类中的变量(PHP基础教程)
|
|