PHP Manual 2016 [4] — 代码重用


很久以前学习的时候记录的,正在整理中…希望能帮助到一些人…禁止转载!


<?php
# include/require | 代码重用
# include() / require() 载入文件
# include()如果载入的文件不存在,提示警告错误,程序还可以继续执行
# require()如果载入的文件不存在,提示致命性错误,程序终止
# include_once() / require_once() 只载入一次文件,如果载入过将不再载入!
# 其实就相当于把A.php放在了B.php里

# A.php
function jau($cac){
echo $cac;
}

# B.php
include "A.php";
jau('cda');

# B.php
require "A.php";
jau('cbc');

include "AAAA.php";
echo "Success Run Next Code";

require "AAAA.php";
echo "FINAL";

include_once "A.php";
include_once "A.php";
include_once "A.php";

require_once "A.php";
require_once "A.php";
require_once "A.php";

# C.php
function cjau($ccac){
echo $ccac;
}
$jte = 6000;
echo jte;

# D.php
include "C.php";
$jte = 1000;
echo $jte;

?>