From 46a2d5e65bb61475dc2fb143e8125f16ef3fd0a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BB=98=E7=A8=8B=E7=95=85?= <2029006014@qq.com> Date: Tue, 17 May 2022 19:27:29 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20220517\344\275\234\344\270\232.md" | 149 ++++++++++++++++++ 1 file changed, 149 insertions(+) create mode 100644 "\344\273\230\347\250\213\347\225\205/20220517\344\275\234\344\270\232.md" diff --git "a/\344\273\230\347\250\213\347\225\205/20220517\344\275\234\344\270\232.md" "b/\344\273\230\347\250\213\347\225\205/20220517\344\275\234\344\270\232.md" new file mode 100644 index 0000000..d8fbd89 --- /dev/null +++ "b/\344\273\230\347\250\213\347\225\205/20220517\344\275\234\344\270\232.md" @@ -0,0 +1,149 @@ + + +``` +brand=$brand; + $this->price=$price; + } + function show(){ + echo "品牌".$this->brand."
价格为".$this->price; + } + + /** + * @return mixed + */ + public function getBrand() + { + return $this->brand; + } + + /** + * @param mixed $brand + */ + public function setBrand($brand): void + { + $this->brand = $brand; + } + + /** + * @param mixed $price + * @return car + */ + public function setPrice($price) + { + $this->price = $price; + return $this; + } + + /** + * @return mixed + */ + public function getPrice() + { + return $this->price; + } + +} +$a=new car("幻影",9999999999); +$a->show(); + +//子类 +class sportscar extends car{ + function __construct($brand, $price) + { + parent::__construct($brand, $price); + } + + function run() + { + echo "名为".parent::getBrand()."的跑车,它车速超越所有车辆,这台超跑的价格为".parent::getPrice(); + } + + +} +$b=new sportscar("法拉利",19000000); +$b->run(); + + +//3、 定义一个类,分别定义3个公共的属性和方法,3个受保护的属性和方法,3个私有属性和方法。 +class lei{ + var $a; + var $b; + var $c; + protected $d; + protected $e; + protected $f; + private $g; + private $h; + private $i; + /** + * @return mixed + */public function getG() +{ + return $this->g; +}/** + * @param mixed $g + */public function setG($g): void +{ + $this->g = $g; +}/** + * @return mixed + */public function getH() +{ + return $this->h; +}/** + * @param mixed $h + */public function setH($h): void +{ + $this->h = $h; +}/** + * @return mixed + */public function getI() +{ + return $this->i; +}/** + * @param mixed $i + */public function setI($i): void +{ + $this->i = $i; +} + function a(){ + + } + function b(){ + + } + function c(){ + + } + protected function d(){ + + } + protected function e(){ + + } + protected function f(){ + + } + private function g(){ + + } + private function h(){ + + } + private function i(){ + + } +} +``` \ No newline at end of file -- Gitee