From dbc739f1c66b56e99f7b7ae13dbf552df6cf948c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=8E=E5=85=B4=E8=89=AF?= <10465762+andewr@user.noreply.gitee.com> Date: Tue, 17 May 2022 17:11:39 +0800 Subject: [PATCH] asd --- ...42\345\220\221\345\257\271\350\261\241.md" | 148 ++++++++++++++++++ 1 file changed, 148 insertions(+) create mode 100644 "\351\273\216\345\205\264\350\211\257/20220517-php\351\235\242\345\220\221\345\257\271\350\261\241.md" diff --git "a/\351\273\216\345\205\264\350\211\257/20220517-php\351\235\242\345\220\221\345\257\271\350\261\241.md" "b/\351\273\216\345\205\264\350\211\257/20220517-php\351\235\242\345\220\221\345\257\271\350\261\241.md" new file mode 100644 index 0000000..df430a4 --- /dev/null +++ "b/\351\273\216\345\205\264\350\211\257/20220517-php\351\235\242\345\220\221\345\257\271\350\261\241.md" @@ -0,0 +1,148 @@ +# 作业 +```php +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("劳斯莱斯",180000); +$a->show(); + +//子类 +class sportscar extends car{ + function __construct($brand, $price) + { + parent::__construct($brand, $price); + } + + function run() + { + echo "名为".parent::getBrand()."的跑车,它车速能达到光速,这台跑车的价格为".parent::getPrice(); + } + + +} +$b=new sportscar("兰博基尼",1000000); +$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