From de89fd9f72c28dc004f5073bc384500599144a4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BB=BB=E6=B1=9F=E4=B8=BD?= <1522389739@qq.com> Date: Tue, 17 May 2022 15:10:32 +0000 Subject: [PATCH] 1 --- .../20220517-\345\257\271\350\261\241.md" | 70 +++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 "\344\273\273\346\261\237\344\270\275/20220517-\345\257\271\350\261\241.md" diff --git "a/\344\273\273\346\261\237\344\270\275/20220517-\345\257\271\350\261\241.md" "b/\344\273\273\346\261\237\344\270\275/20220517-\345\257\271\350\261\241.md" new file mode 100644 index 0000000..07ac8d3 --- /dev/null +++ "b/\344\273\273\346\261\237\344\270\275/20220517-\345\257\271\350\261\241.md" @@ -0,0 +1,70 @@ +price=$price; + $this->type=$type; + } + function show(){ + echo " + 这辆车的品牌为: $this->type, + 价格为:$this->price 元 + "; + } +} +$a=new car(1000000,"兰博基尼"); +$a->show(); +//2、 在上例的基础上为汽车类定义一个子类——跑车类。为子类实例化对象并访问父类的属性。 +class roadster extends car{ + + +} +$b=new roadster(3000000,"保时捷"); +$b->show(); +//3、 定义一个类,分别定义3个公共的属性和方法,3个受保护的属性和方法,3个私有属性和方法。 +class demo{ + public $a; + public $b; + public $c; + public function a(){ + + } + public function b(){ + + } + public function c(){ + + } + protected $a1; + protected $b1; + protected $c1; + protected function a1(){ + +} + protected function b1(){ + + } + protected function c1(){ + + } + private $a2; + private $b2; + private $c2; + private function a2(){ + + } + private function b2(){ + + } + private function c2(){ + + } + +} \ No newline at end of file -- Gitee