手机
当前位置:查字典教程网 >编程开发 >php教程 >php中的路径问题与set_include_path使用介绍
php中的路径问题与set_include_path使用介绍
摘要:first:php中常用的路径当前文件路径:D:phpwebphp_exampleinclude_path.php复制代码代码如下:1.di...

first:

php中常用的路径

当前文件路径:D:phpwebphp_exampleinclude_path.php

复制代码 代码如下:

1.dirname(__FILE__); //输出D:phpwebphp_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

?>

【php中的路径问题与set_include_path使用介绍】相关文章:

php计数器的设计与实现第1/2页

php开发中的页面跳转方法总结

PHP SPL标准库中的常用函数介绍

PHP中GET变量的使用

PHP中的命名空间详细介绍

php中set_error_handler的用法总结

php中file_exists函数使用详解

php的计数器程序

php中smarty变量修饰用法实例分析

PHP中路径问题的解决方案

精品推荐
分类导航