From 7ba2f51f3ad71fa64982e5470c8fda454b4b106a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=96=B9=E7=90=BC?= <2910196733@qq.com>
Date: Tue, 17 May 2022 15:07:15 +0000
Subject: [PATCH] =?UTF-8?q?=E4=BD=9C=E4=B8=9A?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
...71\350\261\241\344\275\234\344\270\232.md" | 74 +++++++++++++++++++
1 file changed, 74 insertions(+)
create mode 100644 "\346\226\271\347\220\274/20220517-php\351\235\242\345\220\221\345\257\271\350\261\241\344\275\234\344\270\232.md"
diff --git "a/\346\226\271\347\220\274/20220517-php\351\235\242\345\220\221\345\257\271\350\261\241\344\275\234\344\270\232.md" "b/\346\226\271\347\220\274/20220517-php\351\235\242\345\220\221\345\257\271\350\261\241\344\275\234\344\270\232.md"
new file mode 100644
index 0000000..20c8fa5
--- /dev/null
+++ "b/\346\226\271\347\220\274/20220517-php\351\235\242\345\220\221\345\257\271\350\261\241\344\275\234\344\270\232.md"
@@ -0,0 +1,74 @@
+```php
+brand=$brand;
+ $this->price=$price;
+ }
+ function run(){
+ 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;
+ }
+
+
+}
+$cc =new Car("本田","五万元");
+$cc->run();
+echo "
";
+//2、 在上例的基础上为汽车类定义一个子类——跑车类。为子类实例化对象并访问父类的属性。
+
+class runCar extends Car{
+ function __construct($brand, $price)
+ {
+ parent::__construct($brand, $price);
+ }
+ function spe(){
+ echo "这辆跑车的牌子是:".$this->getBrand().",它的价格为:".$this->getPrice();
+ }
+}
+$pc= new runCar("大众","十万元");
+$pc->spe();
+echo "
";
+
+//3、 定义一个类,分别定义3个公共的属性和方法,3个受保护的属性和方法,3个私有属性和方法。
+```
+
--
Gitee