教程集 www.jiaochengji.com
教程集 >  脚本编程  >  php  >  正文 php中set_include_path和require,include介绍

php中set_include_path和require,include介绍

发布时间:2016-10-03   编辑:jiaochengji.com
教程集为您提供php中set,include,path和require,include介绍等资源,欢迎您收藏本站,我们将为您提供最新的php中set,include,path和require,include介绍资源
在php中set_include_path会导致require,include用法不一样了,对于这个问题我们来看一个简单的例子,具体如下。

在PHP中经常使用include,require来引用其他文件,使用相对路径或者绝对路径,如果通过set_include_path函数或者ini_set(‘include_path’,xxx)设置include_path配置选项,那么require文件如果在其他目录也可以直接引用。

设置include_path配置选项

如:require_once “class.smarttemplate.php”,这个文件其实并不在当前文件所在目录,但是同样可以这样直接引用。因为前面通过ini_set设置了include_path:

PHP

// 包含配置文件和函数库路径
ini_set('include_path', INCLUDE_PATH . DS . "library" . PATH_SEPARATOR . ini_get('include_path'));


set_include_path函数

set_include_path函数和ini_set(‘include_pah’,xxx)作用是一样的,只不过ini_set方式适合所有PHP版本,对现在来说两者没有差别。

您可能感兴趣的文章:
php中set_include_path和require,include介绍
php中set_include_path与get_include_path例子
详解PHP中include与require的用法区别
php中的include,require,include_once,require_once
php 5.2.x中require、include的区别
PHP中include()与require()的区别有哪些
php引入文件的方法有哪些
php中的include()与require()的对比分析
php开发一个简单的MVC
PHP include_path 用法详解

[关闭]
~ ~