Home >Backend Development >PHP Tutorial >How to dynamically create a Web site with PHP_PHP tutorial
PHP has 4 functions for using external functions: include(), include_once(), require() and require_once().
In order to use them, the following lines of code will be included in the PHP script:
include_once(' arr.php');
require('/path/to/filename.html');
The difference between two types of external functions:
It is exactly the same to use, but it will be different when an error occurs : If the include() function does not work, a script will be printed to the web browser, but the script will continue to run. If require() fails, an error will be printed and the script will terminate.
There is also a *_once() version of these two functions, which guarantees that the file being considered will only be included once, regardless of how many times the script may try to include it.
eg:
字符 |
含义 |
示例 |
Y |
用4位数字表示年 |
2005 |
y |
用2位数字表示年 |
05 |
n |
用1位或2位数字表示月份 |
2 |
m |
用2位数字表示月份 |
02 |
F |
月份 |
February |
M |
用3个字母表示月份 |
Feb |
j |
用1位或2位表示一月中的某一天 |
8 |
d |
用2位数字表示一月中的某一天 |
08 |
l |
星期几 |
Monday |
D |
用三个字母表示星期几 |
Mon |
g |
小时,用1位或2位数字表示的12小时格式 |
6 |
G |
小时,用1位或2位数字表示的24位小时格式 |
18 |
h |
小时,用2位数字表示的12小时格式 |
06 |
H |
小时,用2位数字表示的24小时格式 |
18 |
i |
分 |
45 |
s |
秒 |
18 |
a |
am或pm |
am |
A |
AM或PM |
AM |
键 |
值 |
示例 |
year |
年 |
2005 |
mon |
月 |
12 |
month |
月份名称 |
December |
mday |
一月中的某一天 |
25 |
weekday |
星期几 |
Tuesday |
hours |
小时数 |
11 |
minutes |
分钟数 |
56 |
seconds |
秒数 |
47 |
Today is'.date('l').'. The current time is'.date('H:i a').'.
';