要求或包括相对路径

时间:2018-01-12 01:47:26

标签: php

我读了一些代码,我有疑问。

在文件路径中:/home/project/projects/func.php

require_once('include/somePhpCode.php');
include/somePhpCode.php

中的require_once中的

/home/project/projects/include/

很简单,但在文件路径中:/home/project/projects/func.php(同一文件)

require_once('DB.php')

不是/home/project/projects/DB.php而是/home/project/projects/pear/DB.php/

有什么区别?

php.ini

; UNIX: "/path1:/path2"
;include_path = ".:/php/includes"
;
; Windows: "\path1;\path2"
;include_path = ".;c:\php\includes"
;
; PHP's default setting for include_path is ".;/path/to/php/pear"
; http://www.php.net/manual/en/ini.core.php#ini.include-path

; The root of the PHP pages, used only if nonempty.
; if PHP was not compiled with FORCE_REDIRECT, you SHOULD set doc_root
; if you are running php as a CGI under any web server (other than IIS)
; see documentation for security issues.  The alternate is to use the
; cgi.force_redirect configuration below
; http://www.php.net/manual/en/ini.core.php#ini.doc-root
doc_root =

; The directory under which PHP opens the script using /~username used only
; if nonempty.
; http://www.php.net/manual/en/ini.core.php#ini.user-dir
user_dir =

这些是默认值。

如何查找PHP DB.php,与目录不同。

谢谢。

0 个答案:

没有答案