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 0000000000000000000000000000000000000000..07ac8d3630ebe967448dba0308eac07778105db7 --- /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