php中的include() require()

一、include() require() 载入函数

include()和require()的区别

include()如果载入的文件不存在,提示警告错误,程序还可以继续执行

require()如果载入的文件不存在,致命错误,程序终止,不会继续执行

现在我们有2个php文件,1.php 和2.php,我们想要在2.php中引入1.php,1.php代码如下

2.php代码如下

这时候我们执行2.php就会发现输出 "你的名字叫百度"

二、include_once() require_once()

include_once()
require_once()
只载入一次文件,如果已经载入过,将不再载入

你可能感兴趣的:(php中的include() require())