From bde05817a19a6e67ec8b3f8ce31b7e0b53eb45f2 Mon Sep 17 00:00:00 2001
From: kuangweijian <867034892@qq.com>
Date: Thu, 10 Mar 2022 18:29:47 +0800
Subject: [PATCH] =?UTF-8?q?=E5=BC=82=E5=B8=B8=E5=A4=84=E7=90=86=EF=BC=8C?=
=?UTF-8?q?=E6=96=87=E4=BB=B6=E7=9B=AE=E5=BD=95=E6=93=8D=E4=BD=9C?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../{05魔术方法 => 05重载}/__get.php | 0
.../set.php => 05重载/__set.php} | 4 ++
07面向对象/11重载.php | 3 ++
11自动加载类/autoload.php | 20 ++++++++++
11自动加载类/classA.php | 6 +++
11自动加载类/classB.php | 6 +++
13会话控制Cookie/01-设置Cookie.php | 3 ++
13会话控制Cookie/note.txt | 4 ++
14错误和异常处理/01try_catch_throw.php | 31 +++++++++++++++
14错误和异常处理/02继承异常类.php | 39 +++++++++++++++++++
.../03致命错误Error类.php | 10 +++++
14错误和异常处理/04-error_log.php | 7 ++++
.../05-set_error_handler.php | 14 +++++++
.../06-错误控制运算符.php | 8 ++++
14错误和异常处理/file | 0
15文件目录操作/01-fopen.php | 18 +++++++++
15文件目录操作/02-readfile.php | 9 +++++
15文件目录操作/03-文件上传.php | 22 +++++++++++
15文件目录操作/04目录操作.php | 26 +++++++++++++
15文件目录操作/fileA | 4 ++
20 files changed, 234 insertions(+)
rename 07面向对象/{05魔术方法 => 05重载}/__get.php (100%)
rename 07面向对象/{05魔术方法/set.php => 05重载/__set.php} (76%)
create mode 100644 07面向对象/11重载.php
create mode 100644 11自动加载类/autoload.php
create mode 100644 11自动加载类/classA.php
create mode 100644 11自动加载类/classB.php
create mode 100644 13会话控制Cookie/01-设置Cookie.php
create mode 100644 13会话控制Cookie/note.txt
create mode 100644 14错误和异常处理/01try_catch_throw.php
create mode 100644 14错误和异常处理/02继承异常类.php
create mode 100644 14错误和异常处理/03致命错误Error类.php
create mode 100644 14错误和异常处理/04-error_log.php
create mode 100644 14错误和异常处理/05-set_error_handler.php
create mode 100644 14错误和异常处理/06-错误控制运算符.php
create mode 100644 14错误和异常处理/file
create mode 100644 15文件目录操作/01-fopen.php
create mode 100644 15文件目录操作/02-readfile.php
create mode 100644 15文件目录操作/03-文件上传.php
create mode 100644 15文件目录操作/04目录操作.php
create mode 100644 15文件目录操作/fileA
diff --git a/07面向对象/05魔术方法/__get.php b/07面向对象/05重载/__get.php
similarity index 100%
rename from 07面向对象/05魔术方法/__get.php
rename to 07面向对象/05重载/__get.php
diff --git a/07面向对象/05魔术方法/set.php b/07面向对象/05重载/__set.php
similarity index 76%
rename from 07面向对象/05魔术方法/set.php
rename to 07面向对象/05重载/__set.php
index 070e1f6..8ac51ae 100644
--- a/07面向对象/05魔术方法/set.php
+++ b/07面向对象/05重载/__set.php
@@ -1,4 +1,8 @@
\ No newline at end of file
diff --git a/11自动加载类/autoload.php b/11自动加载类/autoload.php
new file mode 100644
index 0000000..696df04
--- /dev/null
+++ b/11自动加载类/autoload.php
@@ -0,0 +1,20 @@
+str.'
';
+
+ $obj2 = new classB();
+ echo $obj2->str.'
';
+?>
\ No newline at end of file
diff --git a/11自动加载类/classA.php b/11自动加载类/classA.php
new file mode 100644
index 0000000..08199d0
--- /dev/null
+++ b/11自动加载类/classA.php
@@ -0,0 +1,6 @@
+
\ No newline at end of file
diff --git a/11自动加载类/classB.php b/11自动加载类/classB.php
new file mode 100644
index 0000000..a778d42
--- /dev/null
+++ b/11自动加载类/classB.php
@@ -0,0 +1,6 @@
+
\ No newline at end of file
diff --git a/13会话控制Cookie/01-设置Cookie.php b/13会话控制Cookie/01-设置Cookie.php
new file mode 100644
index 0000000..69007d5
--- /dev/null
+++ b/13会话控制Cookie/01-设置Cookie.php
@@ -0,0 +1,3 @@
+
\ No newline at end of file
diff --git a/13会话控制Cookie/note.txt b/13会话控制Cookie/note.txt
new file mode 100644
index 0000000..48782db
--- /dev/null
+++ b/13会话控制Cookie/note.txt
@@ -0,0 +1,4 @@
+会话控制的思想就是允许服务器跟踪同一个客户端做出的连续请求
+
+Cookie 是由 Web 服务器保存在用户浏览器(客户端)上的小文本文件
+
diff --git a/14错误和异常处理/01try_catch_throw.php b/14错误和异常处理/01try_catch_throw.php
new file mode 100644
index 0000000..b85771b
--- /dev/null
+++ b/14错误和异常处理/01try_catch_throw.php
@@ -0,0 +1,31 @@
+';
+ }else{
+ $errMsg = '这是一条抛出异常信息'; //异常信息
+ $errCode = '101'; //异常代码
+ throw new Exception($errMsg, $errCode); //实例一个Exception类,抛出
+
+ echo 'throw后的代码'.'
';
+ }
+ }
+ catch (Exception $e) //捕捉异常, 为什么实例$e有try{}中 new Exception中的信息?
+ {
+ echo '异常信息:' . $e->getMessage() . '
';
+ echo '异常代码:' . $e->getCode() . '
';
+ }
+
+ echo '继续执行 try catch 以外的代码';
+?>
diff --git a/14错误和异常处理/02继承异常类.php b/14错误和异常处理/02继承异常类.php
new file mode 100644
index 0000000..e050fc9
--- /dev/null
+++ b/14错误和异常处理/02继承异常类.php
@@ -0,0 +1,39 @@
+getFile().' '.$this->getLine().'
';
+ }
+ }
+
+ class nameException extends Exception{}
+
+ function reg($reg){
+
+ if (empty($reg['email'])) { //如果数组reg里键email的值是空的
+ throw new emailException("email is null",1);//2.抛出异常后推出了函数
+ }
+
+ echo "-----".'
'; //代码没有执行到这里
+
+ if (empty($reg['name'])) {
+ throw new nameException('name is null',2);
+ }
+
+ echo "-----".'
';
+ }
+
+ try {
+ $reg = array('phone'=>'12344544');
+ reg($reg); //1.传入的数组里没有eamil和name
+ } catch (emailException $e) { //3.捕获的是email is null这个异常
+ echo $e;
+ } catch (nameException $e) { //代码没有进入这个catch
+ echo $e->getMessage().'
';
+ echo $e->getCode().'
';
+ } finally { //4.最后进入finally
+ echo "finally";
+ }
+
+
+?>
\ No newline at end of file
diff --git a/14错误和异常处理/03致命错误Error类.php b/14错误和异常处理/03致命错误Error类.php
new file mode 100644
index 0000000..b4a3b9f
--- /dev/null
+++ b/14错误和异常处理/03致命错误Error类.php
@@ -0,0 +1,10 @@
+getMessage().'
';
+ echo $e->getLine().'
';
+ }
+
+ $b=new eat();
+?>
\ No newline at end of file
diff --git a/14错误和异常处理/04-error_log.php b/14错误和异常处理/04-error_log.php
new file mode 100644
index 0000000..2eaa6bf
--- /dev/null
+++ b/14错误和异常处理/04-error_log.php
@@ -0,0 +1,7 @@
+
\ No newline at end of file
diff --git a/14错误和异常处理/05-set_error_handler.php b/14错误和异常处理/05-set_error_handler.php
new file mode 100644
index 0000000..958a2ee
--- /dev/null
+++ b/14错误和异常处理/05-set_error_handler.php
@@ -0,0 +1,14 @@
+';
+ echo "errstr".$errstr.'
';
+ echo "errfile".$errfile.'
';
+ echo "errline".$errline.'
';
+ die("something error");
+ }
+
+ set_error_handler("error_handler");
+
+ //产生一个用户级别的error
+ trigger_error("this is a error") //当异常发生时,自动调用自定义函数error_handler
+?>
\ No newline at end of file
diff --git a/14错误和异常处理/06-错误控制运算符.php b/14错误和异常处理/06-错误控制运算符.php
new file mode 100644
index 0000000..a219e66
--- /dev/null
+++ b/14错误和异常处理/06-错误控制运算符.php
@@ -0,0 +1,8 @@
+
\ No newline at end of file
diff --git a/14错误和异常处理/file b/14错误和异常处理/file
new file mode 100644
index 0000000..e69de29
diff --git a/15文件目录操作/01-fopen.php b/15文件目录操作/01-fopen.php
new file mode 100644
index 0000000..80155de
--- /dev/null
+++ b/15文件目录操作/01-fopen.php
@@ -0,0 +1,18 @@
+';
+
+ //打开文件
+ $ret = fopen($file,"r");
+ echo $ret.'
';
+
+ //关闭文件
+ $ret = fclose($ret);
+ echo $ret.'
';
+
+
+
+?>
\ No newline at end of file
diff --git a/15文件目录操作/02-readfile.php b/15文件目录操作/02-readfile.php
new file mode 100644
index 0000000..28a427c
--- /dev/null
+++ b/15文件目录操作/02-readfile.php
@@ -0,0 +1,9 @@
+';
+
+ /**
+ * 疑问:这个缓冲区buf有多大?
+ */
+?>
\ No newline at end of file
diff --git a/15文件目录操作/03-文件上传.php b/15文件目录操作/03-文件上传.php
new file mode 100644
index 0000000..c6a9b1b
--- /dev/null
+++ b/15文件目录操作/03-文件上传.php
@@ -0,0 +1,22 @@
+
+
+
"; + print_r($arr); + + //关闭目录 + closedir($dirinfo); + + //删除空目录 + rmdir($dir); +?> \ No newline at end of file diff --git a/15文件目录操作/fileA b/15文件目录操作/fileA new file mode 100644 index 0000000..ec50a5c --- /dev/null +++ b/15文件目录操作/fileA @@ -0,0 +1,4 @@ +窗前明月光 +$filename:要读取的文件名或文件路径; +$use_include_path:可选参数,用来设定是否想要在 include_path 中搜索该文件,默认为 FALSE; +$context:Stream 上下文(context)。 \ No newline at end of file