php中的路径问题与set_include_path使用介绍

first: PHP中常用的路径 当前文件路径:D:\PHPweb\PHP_example\include_path.PHP
<div class="codetitle"><a style="CURSOR: pointer" data="23690" class="copybut" id="copybut23690" onclick="doCopy('code23690')"> 代码如下:

<div class="codebody" id="code23690">
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
可以用下面的方法,在原有目录上添加目录
<div class="codetitle"><a style="CURSOR: pointer" data="15404" class="copybut" id="copybut15404" onclick="doCopy('code15404')"> 代码如下:
<div class="codebody" id="code15404">
<?PHP
$path = '/usr/lib/pear';
set_include_path(get_include_path() . PATH_SEParaTOR . $path);//设置后的include_path变为类似/usr/lib/function;/usr/lib/pear
?>

set_include_path路径问

相关文章

统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
前言 之前做了微信登录,所以总结一下微信授权登录并获取用户...
FastAdmin是我第一个接触的后台管理系统框架。FastAdmin是一...
之前公司需要一个内部的通讯软件,就叫我做一个。通讯软件嘛...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...