Home >php教程 >php手册 >php中的路径问题与set_include_path

php中的路径问题与set_include_path

WBOY
WBOYOriginal
2016-06-13 09:43:21764browse

 这篇文章主要介绍了php中的路径问题与set_include_path,需要的朋友可以参考下

first:    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  可以用下面的方法,在原有目录上添加目录   代码如下:      
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn