php手记-set_include_path和get_include_path用法详解
来源:互联网 发布:java多个线程并发实现 编辑:程序博客网 时间:2024/05/21 09:10
set_include_path
先看效果
//假如有段代码是这样的:include("123/test1.php");include("123/test2.php");include("456/test3.php");require("123/test4.php");require("123/test5.php");//现在要把123的目录换了换成567,这下是不是要搬砖了,要改的地方很多,如果在其他php文件里也引用了123目录下的php那就更麻烦了//再看下面的代码 是不是感觉好很多set_include_path("123");include("test1.php");include("test2.php");include("test3.php");require("test4.php");require("test5.php");//在进一步 设置一下 456set_include_path("123:456");//路径间用:隔开,也可以用PATH_SEPARATOR代替:,如set_include_path("123".PATH_SEPARATOR."456")include("test1.php");include("test2.php");include("test3.php");require("test4.php");require("test5.php");//如果123、456目录下都有test1.php,那么那么那个路径在前就使用其下的test1.php,那么上例中使用的肯定是123/test1.php了
作用:
简化文件的管理
get_include_path
作用
获取当前的 include_path 配置选项
例子
set_include_path("test2:test1:test3");echo get_include_path();//output:test2:test1:test3
因此在set_include_path时需要用get_include_path获得之前设定的path(可以是用set_include_path设定 或者在php.ini里面设定的)拼到要设定的路径的前面,避免把被人或系统设定的path替换掉如:
//别人设定的 other.phpset_include_path("test2:test1:test3");echo get_include_path();//output:test2:test1:test3// my.phpset_include_path(get_include_path().PATH_SEPARATOR."test4:test5:test6");echo get_include_path();//output:test2:test1:test3:test4:test5:test6
1 0
- php手记-set_include_path和get_include_path用法详解
- PHP--set_include_path和get_include_path用法详解
- set_include_path和get_include_path用法详解
- set_include_path和get_include_path用法详解
- set_include_path和get_include_path用法详解
- set_include_path和get_include_path用法详解
- set_include_path和get_include_path用法详解
- set_include_path和get_include_path用法详解
- set_include_path和get_include_path用法详解
- set_include_path和get_include_path用法详解
- php的set_include_path与get_include_path()的用法
- 关于get_include_path()和set_include_path()
- set_include_path & get_include_path
- php函数set_include_path()用法详解
- set_include_path()与get_include_path()
- set_include_path, get_include_path 使用
- 设置include和require的目录get_include_path与set_include_path
- set_include_path用法详解
- TCP/IP TIME_WAIT和CLOSE_WAIT
- Mysql索引
- JavaSE(09)(Set集合)
- 安卓系统如何开启和关闭插入耳机时弹出的保护听力对话框
- 【JAVA】使用javax.mail发送邮件
- php手记-set_include_path和get_include_path用法详解
- 详解拷贝构造函数
- 一台机器上启动多个Tomcat
- SVG+CSS3 简单线条动画
- 索引碎片整理
- jdbc 连接oracle单机与集群配置
- 解决手机连接Mac mini 共享的WiFi,mac的hosts不生效的问题
- 十秒钟解决VMware卸载不干净问题
- Spring常用注解,自动扫描装配Bean