php中的路径问题与set_include_path使用介绍
2014-02-11 00:00
1091 查看
first:
php中常用的路径
当前文件路径:D:\phpweb\php_example\include_path.php
second:
php中的set_include_path
在php中,include文件时,当包含路径不为相对也不为绝对时(如:include("example.php")),会先查找include_path所设置的目录,然后再在当前目录查找,这也是为什么很多资料上提到include("./example.php")比include("example.php")效率高的原因。
方法:
1.ini_set("include_path", "/usr/lib/pear"); //所有版本
2.set_include_path("/usr/lib/pear"); //version>=4.3.0
可以用下面的方法,在原有目录上添加目录
php中常用的路径
当前文件路径:D:\phpweb\php_example\include_path.php
1.dirname(__FILE__); //输出D:\phpweb\php_example 2.$_SERVER['SCRIPT_FILENAME']; //输出D:/phpweb/php_example/include_path.php
second:
php中的set_include_path
在php中,include文件时,当包含路径不为相对也不为绝对时(如:include("example.php")),会先查找include_path所设置的目录,然后再在当前目录查找,这也是为什么很多资料上提到include("./example.php")比include("example.php")效率高的原因。
方法:
1.ini_set("include_path", "/usr/lib/pear"); //所有版本
2.set_include_path("/usr/lib/pear"); //version>=4.3.0
可以用下面的方法,在原有目录上添加目录
<?php $path = '/usr/lib/pear'; set_include_path(get_include_path() . PATH_SEPARATOR . $path);//设置后的include_path变为类似/usr/lib/function;/usr/lib/pear ?>
相关文章推荐
- CI框架源码完全分析之核心文件(异常处理)Exceptions.php
- PHP Fileinfo获取文件MIME类型
- libvirt/qemu特性之cpu hotplug
- PhpWind 8.7中禁止后台管理员随意修改会员用户名功能
- PHP学习笔记1 - MySQL免安装版配置
- php面向对象
- js在php 中出现 unterminated string literal 解决方法
- 诺基亚Lumia 920/820/620无法连接XP系统电脑的解决方法,MTP驱动
- thinkphp ajax检测是否数据可用
- php理论学习(一)
- PHP curl 采集内容之规则 及图片下载方法2
- PHP curl 采集内容之规则 1
- php 文件上传的基本方法
- php 验证码生成方法 及使用
- PHP 文字,图片水印,缩略图,裁切成小图(大小变小)
- PHP文件下载方式
- php 简单的验证码
- php MVC 及例子解释
- php 文件路径设置 set_include_path(); get_include_path();
- php解析url三个方法与实例