From f7a2e7dc0a85e6f98ab536ad235b11a965ba35e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E7=8F=A9=E5=AE=87?= <1925957642@qq.com> Date: Tue, 17 May 2022 23:21:32 +0800 Subject: [PATCH] v --- ...42\345\220\221\345\257\271\350\261\241.md" | 129 ++++++++++++++++++ 1 file changed, 129 insertions(+) create mode 100644 "\347\216\213\347\217\251\345\256\207/20220517-php\351\235\242\345\220\221\345\257\271\350\261\241.md" diff --git "a/\347\216\213\347\217\251\345\256\207/20220517-php\351\235\242\345\220\221\345\257\271\350\261\241.md" "b/\347\216\213\347\217\251\345\256\207/20220517-php\351\235\242\345\220\221\345\257\271\350\261\241.md" new file mode 100644 index 0000000..b34886f --- /dev/null +++ "b/\347\216\213\347\217\251\345\256\207/20220517-php\351\235\242\345\220\221\345\257\271\350\261\241.md" @@ -0,0 +1,129 @@ +# 作业 + +```php+HTML +b=$b; + $this->p=$p; +} +function sc(){ + echo $this->getB().'秋名山神车'.$this->getP().'元子'; +} + + /** + * @return mixed + */ + public function getB() + { + return $this->b; + } + + /** + * @param mixed $b + */ + public function setB($b): void + { + $this->b = $b; + } + + /** + * @return mixed + */ + public function getP() + { + return $this->p; + } + + /** + * @param mixed $p + */ + public function setP($p): void + { + $this->p = $p; + } +} +$a = new car('五菱宏光','2000w'); +$a->sc(); + +//2、 在上例的基础上为汽车类定义一个子类——跑车类。为子类实例化对象并访问父类的属性。*/ +class cp extends car{ + function __construct($b, $p) + { + parent::__construct($b, $p); + } + + function sc() + { + echo $this->getB().$this->getP(); + } +} +$qq= new cp('奔驰','1900w'); +$qq->sc(); +//3、 定义一个类,分别定义3个公共的属性和方法,3个受保护的属性和方法,3个私有属性和方法。 +class lhq{ + var $a; + var $b; + var $c; + function qq(){ + } + function ll() { + } + function hh() { + } + protected $d; + protected $e; + protected $f; + protected function dd() { + } + protected function ss() { + } + protected function xx(){ + } + private $g; + private $h; + private $i; + private function lhqs(){ + + } + private function lhqd(){ + + } + private function lhqb(){ + + } + function getG() + { + return $this->g; + } + function setG($g) { + $this->g = $g; + } + function getH() { + return $this->h; + } + function setH($h) { + $this->h = $h; + } + + function getI() { + return $this->i; + } + function setI($i) { + $this->i = $i; + } + + +} +``` + -- Gitee