我的文件在http://www.example.com/
在/home/www/example.com/www
Debian的挤压运行.
/home/www/example.com/
www/
index.php
php/
include_me.php
Run Code Online (Sandbox Code Playgroud)
在php.ini中我已取消注释并更改为:
include_path =".:/home/www/example.com"
Run Code Online (Sandbox Code Playgroud)
在www中的脚本index.php中,我有require_once("/php/include_me.php")
.我从PHP获得的输出是:
Warning: require_once(/php/include_me.php) [function.require-once]: failed to open stream: No such file or directory in /home/www/example.com/www/index.php on line 2
Fatal error: require_once() [function.require]: Failed opening required '/php/include_me.php' (include_path='.:/home/www/example.com') in /home/www/example.com/www/index.php on line 2
Run Code Online (Sandbox Code Playgroud)
如您所见,include-path根据错误正确设置.但如果我这样做require_once("../php/include_me.php");
,它就有效.因此,include-path必须出错.
有谁知道我能做些什么来解决它?
php/
Run Code Online (Sandbox Code Playgroud)
是一个相对路径,并使用当前目录作为起点
./php/
Run Code Online (Sandbox Code Playgroud)
是一个相对路径,并显式声明当前目录(.)作为起点
/php/
Run Code Online (Sandbox Code Playgroud)
是一个不相对的路径,这意味着它的起点是顶级目录(根目录/)