当我们使用require()、require_once()、__autoload()和
spl_autoload_register() 等语句装载外部文件时,可以使用当前
目录引用已经设置在set_include_path()目录下的文件。
string set_include_path ( string $new_include_path )
$new_include_path是以“;”分隔的引用文件目录列表。
get_include_path()
查看当前系统引用文件的目录列表。
例如,我要设置zend framework的引用目录并且调用Zend_Acl()类
:
//DIRECTORY_SEPARATOR当前系统的目录分隔符
if (!defined('DS')) {
define('DS', DIRECTORY_SEPARATOR);
}
//定义站点根目录
if (!defined('WEB_DIR')) {
define('WEB_DIR', dirname(__FILE__) . DS);
}
//定义引入类库目录
if (!defined('LIBRARY_DIR')) {
define('LIBRARY_DIR', str_replace("ftest1", "library",
WEB_DIR));
}
//设置引用目录
set_include_path(get_include_path
().PATH_SEPARATOR.LIBRARY_DIR);
//使用当前目录引用文件
require_once 'Zend/Acl.php';
//创建引用文件的分类
$acl = new Zend_Acl();
set_include_path()与get_include_path()
最新推荐文章于 2021-03-16 15:06:05 发布