From c0fdaa55d020ba612c242ff700c7db40751267c9 Mon Sep 17 00:00:00 2001 From: pengshiyu <1940607002@qq.com> Date: Thu, 3 Mar 2022 22:58:15 +0800 Subject: [PATCH] fix --- blog/php-basic/include.md | 114 ++++++++++++++++++++++++ blog/php-basic/index.md | 8 +- blog/php-basic/process.md | 183 +++++++++++++++++++++++++++++++++++--- blog/php-basic/system.md | 76 ++++++++++++++++ 4 files changed, 367 insertions(+), 14 deletions(-) create mode 100644 blog/php-basic/include.md create mode 100644 blog/php-basic/system.md diff --git a/blog/php-basic/include.md b/blog/php-basic/include.md new file mode 100644 index 0000000..25bf64b --- /dev/null +++ b/blog/php-basic/include.md @@ -0,0 +1,114 @@ +# PHP 文件包含 + +在一个 PHP 脚本中,去将另一个文件包含进来 + +## 文件包含的作用 + +实现代码共享重用,协作共同完成一件事 + +1. 使用被包含文件中的内容:向上包含(所要) + +2. 自己的东西可以给别的文件使用:向下包含(给与) + +## 文件包含的四种形式 + +1. include 包含文件 +2. include_once 一个文件最多被包含一次 +3. require 与 include 相同 +4. require_once 与 include_once 相同 + +语法 + +``` +include '文件路径'; +include('文件路径'); +``` + +- 向上包含:先包含文件,再使用文件中的内容 +- 向下包含:先准备内容,然后包含另外的文件,在另外的文件中使用当前内容 + +示例: 向上包含 + +```php + + + + + + + + + + +``` + +``` +1 * 1 = 1 +2 * 1 = 2 2 * 2 = 4 +3 * 1 = 3 3 * 2 = 6 3 * 3 = 9 +4 * 1 = 4 4 * 2 = 8 4 * 3 = 12 4 * 4 = 16 +5 * 1 = 5 5 * 2 = 10 5 * 3 = 15 5 * 4 = 20 5 * 5 = 25 +6 * 1 = 6 6 * 2 = 12 6 * 3 = 18 6 * 4 = 24 6 * 5 = 30 6 * 6 = 36 +7 * 1 = 7 7 * 2 = 14 7 * 3 = 21 7 * 4 = 28 7 * 5 = 35 7 * 6 = 42 7 * 7 = 49 +8 * 1 = 8 8 * 2 = 16 8 * 3 = 24 8 * 4 = 32 8 * 5 = 40 8 * 6 = 48 8 * 7 = 56 8 * 8 = 64 +9 * 1 = 9 9 * 2 = 18 9 * 3 = 27 9 * 4 = 36 9 * 5 = 45 9 * 6 = 54 9 * 7 = 63 9 * 8 = 72 9 * 9 = 81 +``` + +另一种书写for的方式 + +```php + + + + + + + + + +
+``` + +PHP在HTML中应该只做数据输出 +``` +if() {} => if(): endif; +``` \ No newline at end of file diff --git a/blog/php-basic/system.md b/blog/php-basic/system.md new file mode 100644 index 0000000..5cfe11d --- /dev/null +++ b/blog/php-basic/system.md @@ -0,0 +1,76 @@ +# PHP 常用的系统函数 + +## 输出函数 + +- print() 类似 echo 输出,返回 1 +- print_r() 类似 var_dump(), 不会输出类型,只会输出值 + +```php += 5.0.0 get_as_float=true,microtime() 将返回一个浮点数 + +// eg: +echo microtime(); +// 0.61349600 1646316936 + +echo microtime(true); +// 1646317009.6239 +``` + +4、strtotime(): 将任何字符串的日期时间描述解析为 Unix 时间戳 + +```php +strtotime(string $datetime, int $now = time()): int + +// eg: +echo strtotime('2022-03-03 22:13:20'); +// 1646316800 +``` -- GitLab