/index.php
/include/config.php
下面是index.php
<?php $path = ‘/usr/lib/pear‘; set_include_path(get_include_path() . PATH_SEPARATOR . $path); //设置后的include_path变为类似/usr/lib/function;/usr/lib/pear include("config.php"); //先搜索当前目录->搜索get_include_path()列出的路径 ?>
输出一下
<?php echo get_include_path(); ?>
结果
/user/tpls;/usr/lib/function;/usr/lib/pear;
这类似于java中的类加载路径,加载一个文件时,在扫描当前目录之后,将在上述3个路径下查找。
时间: 2024-08-10 04:40:28