diff --git "a/\346\235\216\345\256\266\347\216\262/20220510-\351\235\231\345\244\234\346\200\235\345\222\214\350\207\252\346\210\221\344\273\213\347\273\215.md.txt" "b/\346\235\216\345\256\266\347\216\262/20220510-\351\235\231\345\244\234\346\200\235\345\222\214\350\207\252\346\210\221\344\273\213\347\273\215.md" similarity index 100% rename from "\346\235\216\345\256\266\347\216\262/20220510-\351\235\231\345\244\234\346\200\235\345\222\214\350\207\252\346\210\221\344\273\213\347\273\215.md.txt" rename to "\346\235\216\345\256\266\347\216\262/20220510-\351\235\231\345\244\234\346\200\235\345\222\214\350\207\252\346\210\221\344\273\213\347\273\215.md" diff --git "a/\346\235\216\345\256\266\347\216\262/20220516-\346\225\260\347\273\204\345\222\214\345\207\275\346\225\260\345\222\214\345\255\227\347\254\246\344\270\262.md.md" "b/\346\235\216\345\256\266\347\216\262/20220516-\346\225\260\347\273\204\345\222\214\345\207\275\346\225\260\345\222\214\345\255\227\347\254\246\344\270\262.md" similarity index 100% rename from "\346\235\216\345\256\266\347\216\262/20220516-\346\225\260\347\273\204\345\222\214\345\207\275\346\225\260\345\222\214\345\255\227\347\254\246\344\270\262.md.md" rename to "\346\235\216\345\256\266\347\216\262/20220516-\346\225\260\347\273\204\345\222\214\345\207\275\346\225\260\345\222\214\345\255\227\347\254\246\344\270\262.md" diff --git "a/\346\235\216\345\256\266\347\216\262/20220517-\350\275\246.md" "b/\346\235\216\345\256\266\347\216\262/20220517-\350\275\246.md" new file mode 100644 index 0000000000000000000000000000000000000000..d6e499ef9547a5f288adfbba8f91f78eb7c4a603 --- /dev/null +++ "b/\346\235\216\345\256\266\347\216\262/20220517-\350\275\246.md" @@ -0,0 +1,238 @@ +```php +brand=$brand; + $this->price=$price; + } + function hao(){ + echo $this->brand."的价格为:".$this->price; + } + + + + /** + * @return mixed + */ + public function getBrand() + { + return $this->brand; + } + + /** + * @param mixed $brand + */ + public function setBrand($brand) + { + $this->brand = $brand; + } + + /** + * @return mixed + */ + public function getPrice() + { + return $this->price; + } + + /** + * @param mixed $price + */ + public function setPrice($price) + { + $this->price = $price; + } +} + +$ha=new car("奥迪","300000"); +$ha->hao(); + + + +echo "
"; +//2、在上例的基础上为汽车类定义一个子类——跑车类。为子类实例化对象并访问父类的属性。 + +class pao extends car{ + private $brand;//品牌 + private $price;//价格 + + + public function __construct($brand,$price) + { + $this->brand=$brand; + $this->price=$price; + } + function jiu(){ + echo $this->brand."的价格为:".$this->price; + } + + + + /** + * @return mixed + */ + public function getBrand() + { + return $this->brand; + } + + /** + * @param mixed $brand + */ + public function setBrand($brand) + { + $this->brand = $brand; + } + + /** + * @return mixed + */ + public function getPrice() + { + return $this->price; + } + + /** + * @param mixed $price + */ + public function setPrice($price) + { + $this->price = $price; + } +} + +$y=new pao("奔驰","400000"); +$y->jiu(); + + +//3、定义一个类,分别定义3个公共的属性和方法,3个受保护的属性和方法,3个私有属性和方法。 +//3个公共的属性和方法 +class shu +{ + public $a1; + + public $a2; + + pubLic $a3; + + function name1() + { + + + echo "我叫" . $this->a1; + } + + function age1() + + { + echo "我" . $this->a2 . "岁了"; + } + + function love1() + + { + echo "我的爱好是" . $this->a3; + } + +//3个受保护的属性和方法 + + protected $b1; + + protected $b2; + + protected $b3; + + protected function name2() + { + } + + protected function age2() + + { + echo "我" . $this->a2 . "岁了"; + } + + protected function love2() + + { + echo "我的爱好是" . $this->a3; + } + + + //3个私有属性和方法 + + private $c1; + + private $c2; + + private $c3; + + private function name3() + { + } + + private function age3() + { + } + + private function love3() + { + } + + public function getC1() + + { + return $this->c1; + } + + + public function setC1($c1) + { + + $this->c1 = $c1; + } + + + public function getC2() + { + + return $this->c2; + } + + + public function setC2($c2) + { + + $this->c2 = $c2; + } + + + public function getC3() + { + + return $this->c3; + } + + + public function setC3($c3) + { + + $this->c3 = $c3; + + } +} +``` \ No newline at end of file