From b7f3f980934fef3729a9b2b38c9986ed69188590 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=AD=E6=95=8F=E5=8D=8E?= <2557181397@qq.com> Date: Tue, 17 May 2022 22:04:59 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...71\350\261\241\347\273\203\344\271\240.md" | 199 ++++++++++++++++++ 1 file changed, 199 insertions(+) create mode 100644 "\350\260\255\346\225\217\345\215\216/20220517-PHP\351\235\242\345\220\221\345\257\271\350\261\241\347\273\203\344\271\240.md" diff --git "a/\350\260\255\346\225\217\345\215\216/20220517-PHP\351\235\242\345\220\221\345\257\271\350\261\241\347\273\203\344\271\240.md" "b/\350\260\255\346\225\217\345\215\216/20220517-PHP\351\235\242\345\220\221\345\257\271\350\261\241\347\273\203\344\271\240.md" new file mode 100644 index 0000000..a3174d6 --- /dev/null +++ "b/\350\260\255\346\225\217\345\215\216/20220517-PHP\351\235\242\345\220\221\345\257\271\350\261\241\347\273\203\344\271\240.md" @@ -0,0 +1,199 @@ +```php+HTML +brand=$brand; + $this->price=$price; + } + + /** + * @return mixed + */ + public function getBrand() + { + return $this->brand; + } + + /** + * @param mixed $brand + */ + public function setBrand($brand): void + { + $this->brand = $brand; + } + + /** + * @return mixed + */ + public function getPrice() + { + return $this->price; + } + + /** + * @param mixed $price + */ + public function setPrice($price): void + { + $this->price = $price; + } + public function show(){ + echo '顶级超跑'.$this->brand.'价格在'.$this->price."万左右"; + } + +} + + +//2、 在上例的基础上为汽车类定义一个子类——跑车类。为子类实例化对象并访问父类的属性。 +// 子类-跑车 +class Sports extends Automobile { + public function __construct($brand, $price) + { + parent::__construct($brand, $price); + } + + public function show() + { // 方法重写: + parent::show(); + echo "\t,速度马力在其10倍"; + } + +} + + + +// 实例化 +$A = new Automobile("凯迪拉克x8",88); +$S = new Sports("凯迪拉克XLR",1000); +// 引用 +$A->show(); +echo "
"; +$S->show(); + + + +//3、 定义一个类,分别定义3个公共的属性和方法,3个受保护的属性和方法,3个私有属性和方法。 +class Kind{ + // 3个公共的属性和方法 + public $name; + public $sex; + public $age; + + public function Way() + { + + } + public function Way2() + { + + } + public function Way3() + { + + } + + + + // 3个私有属性和方法 + private $height; + private $avoirdupois; + private $hobby; + + /** + * @return mixed + */ + public function getHeight() + { + return $this->height; + } + + /** + * @param mixed $height + */ + public function setHeight($height): void + { + $this->height = $height; + } + + /** + * @return mixed + */ + public function getAvoirdupois() + { + return $this->avoirdupois; + } + + /** + * @param mixed $avoirdupois + */ + public function setAvoirdupois($avoirdupois): void + { + $this->avoirdupois = $avoirdupois; + } + + /** + * @return mixed + */ + public function getHobby() + { + return $this->hobby; + } + + /** + * @param mixed $hobby + */ + public function setHobby($hobby): void + { + $this->hobby = $hobby; + } + + private function A() + { + + } + private function A1() + { + + } + private function A2() + { + + } + + + + // 3个受保护的属性和方法 + protected $basketball; + protected $football; + protected $badminton; + + protected function B1() + { + + } + protected function B2() + { + + } + protected function B3() + { + + } + +} +``` + -- Gitee From 71aa6189c971680728df9b8e0fb22e3abb4fbb82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=AD=E6=95=8F=E5=8D=8E?= <2557181397@qq.com> Date: Sun, 22 May 2022 21:40:45 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...07\344\273\266\344\270\212\344\274\240.md" | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 "\350\260\255\346\225\217\345\215\216/20220518-PHP\346\226\207\344\273\266\344\270\212\344\274\240.md" diff --git "a/\350\260\255\346\225\217\345\215\216/20220518-PHP\346\226\207\344\273\266\344\270\212\344\274\240.md" "b/\350\260\255\346\225\217\345\215\216/20220518-PHP\346\226\207\344\273\266\344\270\212\344\274\240.md" new file mode 100644 index 0000000..825e922 --- /dev/null +++ "b/\350\260\255\346\225\217\345\215\216/20220518-PHP\346\226\207\344\273\266\344\270\212\344\274\240.md" @@ -0,0 +1,57 @@ +```php+HTML + + + + + 文件上传 + + +
+ 文件上传: +
+ +
+ + + + + +SIZE){ + echo "文件过大上传失败"; + }else{ + echo "文件大小符合可以上传"; + // 限制上传类型 + echo "
"; + $array = array("pdf","doc");// 设置类型 + $name = $_FILES['wj']['name'];// 字符串分割为数组 + $nameArr = explode('.',$name);// + $LastName = end($nameArr);// 得到上传类型 + // 文件类型与设置类型比较 + $bj = in_array($LastName,$array); + if ($bj===true){ + echo "类型符合上传成功"; + }else { + echo "类型不符上传失败"; + } + } +} +``` + -- Gitee