string set_include_path ( string $new_include_path )

为当前脚本设置 include_path 运行时的配置选项。

Example #2 添加到include path

利用常量 PATH_SEPARATOR 可跨平台扩展 include path。

这个例子中我们把 /usr/lib/pear 添加到了 现有的 include_path 的尾部。

<?php
$path = '/usr/lib/pear';
set_include_path(get_include_path() . PATH_SEPARATOR . $path);
?>
 

朋友们 开发的时候 ,总会 遇到 include_once()的情况。有时候,我们需要大量的引用文件,但是被引用文件的路径有时候 是个问题。  我们可以把 经常要引用 的文件,放在一个 文件夹中,我们取名为 include,这样 我们 就把 该文件夹 当做 默认的引用路径。

我们可以 用 set_include_path() 来设定,多个路径 可以用 路径分隔符分开(windows 为';',linux为':')。

例:

define('INCLUDE_PATH','/include/');

set_include_path(INCLUDE);

这样当我们引用 include 中的文件 如 conn.php ,smarty_config.php   时,我们直接可以这样写

include_once('conn.php');

include_once('smarty_config.php');

如果,我们要引用的文件不再 include中时,我们可以在设多个默认路径(当我们要引用的文件,在多个路径中多存在是,我们默认取排在最前的路径)。如下:

define('INCLUDE_PATH','/include/');

define('LIB_PATH','/lib/');

set_include_path(INCLUDE_PATH.PATH_SEPARATOR.LIB_PATH.PATH_SEPARATOR.get_include_path());

(PATH_SEPARATOR为路径分隔符)

php set_include_path的更多相关文章

  1. set_include_path详细解释

    zendframework的示例index.php里有这样一句 set_include_path('.' . PATH_SEPARATOR . '../library/'. PATH_SEPARATO ...

  2. set_include_path — 设置 include_path 配置选项为当前脚本设置 include_path 运行时的配置选项。

    说明 string set_include_path ( string $new_include_path ) 为当前脚本设置 include_path 运行时的配置选项. 参数 new_includ ...

  3. php使用 set_include_path

    通过set_include_path引用home/lib/image.func.php 1.创建include.php 2.添加如下代码 3.在需要引用的文件中包含include.php文件 < ...

  4. set_include_path()的用法

    朋友们 开发的时候 ,总会 遇到 include_once()的情况.有时候,我们需要大量的引用文件,但是被引用文件的路径有时候是个问题.  我们可以把 经常要引用 的文件,放在一个 文件夹中,我们取 ...

  5. php 文件路径设置 set_include_path(); get_include_path();

    <?php set_include_path($string); //设置路径 get_include_path(); // 获取当前的路径 //例如:文件路径为: //D:/phpweb/de ...

  6. set_include_path和get_include_path用法详解

    首先set_include_path这个函数呢,是在脚本里动态地对PHP.ini中include_path进行修改的.而这个include_path呢,它可以针对下面的include和require的 ...

  7. 012PHP文件处理——copy rename file set_include_path

    <?php //copy rename file set_include_path /*file() 以行为单位返回数组 * */ /*$arr=file('b.txt'); foreach ( ...

  8. 【php】set_include_path和get_include_path用法详解

    目的:在框架中方便加载文件 参考:http://blog.sina.com.cn/s/blog_4ce89f200100twbl.html 如果我们没有设置这个值,可能我们需要写一些完全的路径:    ...

  9. Php函数set_include_path()函数详解

    set_include_path--设置include_path配置选项. 说明 string set_include_path(string $new_include_path); 为当前脚本设置i ...

随机推荐

  1. 【Populating Next Right Pointers in Each Node II】cpp

    题目: Follow up for problem "Populating Next Right Pointers in Each Node". What if the given ...

  2. 【CentOS】Eclipse插件egit使用

    1.简介 2.安装 3.配置 4.使用 5.补充说明   参考资料: http://yufenfei.iteye.com/blog/1750124    1.简介     EGit就是一款Eclips ...

  3. BZOJ3874 codevs3361 宅男计划

    AC通道1:http://www.lydsy.com/JudgeOnline/problem.php?id=3874 AC通道2:http://codevs.cn/problem/3361/ [题目分 ...

  4. 【BZOJ】【3856】Monster

    又是一道水题…… 重点是分情况讨论: 首先我们很容易想到,如果a*k-b*(k+1)>0的话那么一定能磨死Monster. 但即使不满足这个条件,还有可能打死boss: 1.h-a<1也就 ...

  5. 土地购买 usaco 斜率优化

    看这道题的时候,感觉很难,因为数据范围比较大,很难dp: 后来想到了[书柜的尺寸]这道题,也是一道dp,曾经看了那道题的题解而深有启发: 这道题每组的付费只与这一组长宽的最大值有关,也就是说要分组,一 ...

  6. 为什么主流网站无法捕获 XSS 漏洞?

    二十多年来,跨站脚本(简称 XSS)漏洞一直是主流网站的心头之痛.为什么过了这么久,这些网站还是对此类漏洞束手无策呢? 对于最近 eBay 网站曝出的跨站脚本漏洞,你有什么想法?为什么会出现这样的漏网 ...

  7. POJ 1222

    EXTENDED LIGHTS OUT Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 6196   Accepted: 40 ...

  8. Xcode显示行号

  9. POJ 1507

    #include<iostream> #include<stdio.h> using namespace std; #include<iomanip> double ...

  10. PATH环境变量和CLASSPATH环境变量详解

    大凡装过JDK的人都知道要安装完成后要设置环境变量,可是为什么要设置环境变量呢?环境变量有什么作用? 1)PATH详解: 计算机安装JDK之后,输入“javac”“java”之类的命令是不能马上被计算 ...