From 969be5668e716348e4547d9cf25a13add0ad1e45 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E9=99=88=E5=87=8C=E8=8A=9D?= <2054884274@qq.com>
Date: Tue, 17 May 2022 14:05:14 +0000
Subject: [PATCH] q
---
"20220517-php\346\226\271\346\263\225.md" | 176 ++++++++++++++++++++++
1 file changed, 176 insertions(+)
create mode 100644 "20220517-php\346\226\271\346\263\225.md"
diff --git "a/20220517-php\346\226\271\346\263\225.md" "b/20220517-php\346\226\271\346\263\225.md"
new file mode 100644
index 0000000..bf446bb
--- /dev/null
+++ "b/20220517-php\346\226\271\346\263\225.md"
@@ -0,0 +1,176 @@
+```php
+brand=$brand;
+ $this->price=$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;
+ }
+
+ function show(){
+ echo "这辆汽车的牌子是:".$this->brand."它的价格为:".$this->price;
+ }
+
+}
+
+$a=new Car("大众","39999");
+$a->show();
+
+echo "
";
+//2、在上例的基础上为汽车类定义一个子类——跑车类。为子类实例化对象并访问父类的属性。
+
+class SportsCar extends Car {
+
+ function __construct($brand, $price)
+ {
+ parent::__construct($brand, $price);
+ }
+
+ function cool(){
+ echo "它看来非常的酷";
+ }
+
+}
+
+$b = new Sportscar("劳斯莱斯","9000000");
+echo "这辆汽车的牌子是:".$this->brand."它的价格为:".$this->price;
+$b->cool();
+echo "
";
+/3、定义一个类,分别定义3个公共的属性和方法,3个受保护的属性和方法,3个私有属性和方法。
+class A{
+
+//公共的
+public $name;
+public $age;
+public $sex;
+ function eat(){
+ echo "吃饭";
+ }
+
+ function sleep(){
+ echo "睡觉";
+ }
+
+ function skill(){//技能
+ echo "手撕鬼子";
+ }
+//受保护的
+protected $height;//身高
+protected $weight;//体重
+protected $address;//地址
+ protected function face(){
+ echo "人脸识别";
+ }
+ protected function short(){
+ echo "验证码";
+ }
+ protected function information(){
+ echo "填写身份证信息";
+ }
+
+//私有的
+private $grade;//成绩
+private $classname;//班级
+private $id;//学号
+ /**
+ * @return mixed
+ */
+ public function getGrade()
+ {
+ return $this->grade;
+ }
+
+ /**
+ * @param mixed $grade
+ */
+ public function setGrade($grade): void
+ {
+ $this->grade = $grade;
+ }
+
+ /**
+ * @return mixed
+ */
+ public function getClassname()
+ {
+ return $this->classname;
+ }
+
+ /**
+ * @param mixed $classname
+ */
+ public function setClassnamel($classname): void
+ {
+ $this->classname = $classname;
+ }
+
+ /**
+ * @return mixed
+ */
+ public function getId()
+ {
+ return $this->id;
+ }
+
+ /**
+ * @param mixed $id
+ */
+ public function setId($id): void
+ {
+ $this->id = $id;
+ }
+
+ private function money{
+ echo "会花钱";
+ }
+ private function book{
+ echo "会看书";
+ }
+ private function attendclass{
+ echo "会上专业课";
+ }
+
+}
+
+```
+
+
+
--
Gitee