我正在尝试通过相对路径require
/include
文件。路径存在并检查所有权限。要包含的脚本是可读的,可以通过浏览器中的 URL 访问...
但是,我收到了无法打开的错误/警告。调用脚本和要包含的文件都在同一台服务器上。
来电者亲属:
/devel/phi/dev/appcenter-head/appcenter/application/nm/index.php
来电者位置:
/home/devel/wwwroot/phi/dev/appcenter-head/appcenter/application/nm
要求亲属:
/devel/nm/dev/http-api/http-api/src/httpapi.inc.php
要求地点:
/home/devel/wwwroot/nm/dev/http-api/http-api/src
我尝试了什么:
$strHttpApiUrl = "/devel/nm/dev/http-api/http-api/index.php";
$strFile = "/src/httpapi.inc.php";
$strDirName = dirname( $strHttpApiUrl );
$strRealpath = realpath( $strDirName . $strFile );
require_once $strRealpath;
失败:PHP Warning: require_once(/home/devel/wwwroot/phi/dev/appcenter-head/appcenter/application/nm) [<a href='function.require-once'>functio
n.require-once</a>]: failed to open stream: No such file or directory in /home/devel/wwwroot/phi/dev/appcenter-head/appcenter/application/nm/class/TWinLogin.php
也失败了:PHP Fatal error: require_once() [<a href='function.require'>function.require</a>]: Failed opening required '' (include_path='.:/opt/nm/appcenter40-server-php53/lib/php')
还尝试了简单的包括字符串 URL 或使用绝对路径...
如何包含该文件?
编辑:
这成功地包含了文件:
require_once '/home/devel/wwwroot/nm/dev/http-api/http-api/src/httpapi.inc.php';
那么如何获得该工作路径,假设我获得以下相对路径:
/devel/nm/dev/http-api/http-api/index.php