From 7a66c08dae4fafba44f6b6ca0ef1b14bae8cf417 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B1=A4=E4=BA=A6=E5=87=A1?= <1044020597@qq.com> Date: Tue, 17 May 2022 05:59:54 +0000 Subject: [PATCH 1/2] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6=20?= =?UTF-8?q?=E6=B1=A4=E4=BA=A6=E5=87=A1/.keep?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "\346\261\244\344\272\246\345\207\241/.keep" | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 "\346\261\244\344\272\246\345\207\241/.keep" diff --git "a/\346\261\244\344\272\246\345\207\241/.keep" "b/\346\261\244\344\272\246\345\207\241/.keep" deleted file mode 100644 index e69de29..0000000 -- Gitee From 428c9f390efa56467bf3cb0b69496a90f81cb520 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B1=A4=E4=BA=A6=E5=87=A1?= <1044020597@qq.com> Date: Tue, 17 May 2022 09:37:08 +0000 Subject: [PATCH 2/2] 1 --- ...42\345\220\221\345\257\271\350\261\241.md" | 120 ++++++++++++++++++ 1 file changed, 120 insertions(+) create mode 100644 "\346\261\244\344\272\246\345\207\241/20220517-php\351\235\242\345\220\221\345\257\271\350\261\241.md" diff --git "a/\346\261\244\344\272\246\345\207\241/20220517-php\351\235\242\345\220\221\345\257\271\350\261\241.md" "b/\346\261\244\344\272\246\345\207\241/20220517-php\351\235\242\345\220\221\345\257\271\350\261\241.md" new file mode 100644 index 0000000..ff5a887 --- /dev/null +++ "b/\346\261\244\344\272\246\345\207\241/20220517-php\351\235\242\345\220\221\345\257\271\350\261\241.md" @@ -0,0 +1,120 @@ +```php +brand=$brand; + $this->price=$price; + } +} +$a =new car("丰田","15万"); +echo "这辆车的品牌为:".$a->brand.",价格为:".$a->price; +echo "
"; +//2、 在上例的基础上为汽车类定义一个子类——跑车类。为子类实例化对象并访问父类的属性。 +class roadster extends car{//跑车 + var $speed; + function __construct($brand,$price,$speed){ + $this->brand=$brand; + $this->price=$price; + $this->speed=$speed; + } + +} +$b =new roadster("法拉利","100万","快"); +echo "这辆车的品牌为:".$b->brand.",价格为:".$b->price.",速度".$b->speed; +echo "
"; +//3、 定义一个类,分别定义3个公共的属性和方法,3个受保护的属性和方法,3个私有属性和方法。 +class cat{ + public $name;//名字 + public $brand;//品种 + public $color;//颜色 + public function eat(){ + echo "会吃饭"; + } + public function sleep(){ + echo "会睡觉"; + } + public function run(){ + echo "会跑"; + } + protected $age;//年龄 + protected $feeling;//感情状况 + protected $character; + + /** + * @return mixed + */ + public function getWeight() + { + return $this->weight; + } + + /** + * @param mixed $weight + */ + public function setWeight($weight): void + { + $this->weight = $weight; + } + + /** + * @return mixed + */ + public function getTall() + { + return $this->tall; + } + + /** + * @param mixed $tall + */ + public function setTall($tall): void + { + $this->tall = $tall; + } + + /** + * @return mixed + */ + public function getSex() + { + return $this->sex; + } + + /** + * @param mixed $sex + */ + public function setSex($sex): void + { + $this->sex = $sex; + }//性格 + protected function like(){ + echo "喜欢玩毛线球"; + } + protected function call(){ + echo "会喵喵喵"; + } + protected function dump(){ + echo "会蹦蹦跳跳"; + } + private $weight; + private $tall; + private $sex; + private function climb{ + echo "会爬树"; + } + private function bite{ + echo "会咬人"; + } + private function heat{ + echo "会发情"; + } +} -- Gitee