include()
获取指定文件中的所有内容并将其包含在当前文件中。
如果发生错误,include()
函数会生成警告,但脚本将继续执行。
被包含文件先按参数给出的路径寻找,如果没有给出目录(只有文件名)时则按照 include_path 指定的目录寻找。如果在 include_path 下没找到该文件则 include 最后才在调用脚本文件所在的目录和当前工作目录下寻找。如果最后仍未找到文件则 include 结构会发出一条警告;
如果定义了路径,那么include_path 将会被完全忽略。
www. On IT Road .com
示例
vars.php
<?php $color = 'green'; $fruit = 'apple'; ?>
test.php
<?php echo "A $color $fruit"; // A include 'vars.php'; echo "A $color $fruit"; // A green apple ?>
日期:2020-09-17 00:10:29 来源:oir作者:oir