realpath 返回空字符串

发布于 2024-12-12 11:19:21 字数 250 浏览 5 评论 0原文

我使用 MediaWiki 但出现错误。我在档案里找到了。这段代码有一行:

$IP = realpath( '.' );

但是 $IP 返回一个空字符串,因此系统中文件的路径不起作用。 (例如,如果 $IP 为 .E:/path_to_wwwroot 则有效)。我该如何解决这个问题。我的提供商是否可能阻止对 realpath 的访问?

谢谢!

I use MediaWiki but there is an error. I found it in the files. There is line with this code:

$IP = realpath( '.' );

But $IP returns an empty string, so the path to the files in the system is not working. (for example if $IP would be . or E:/path_to_wwwroot it works). How can I solve the problem. Is it possible that my provider blocked access to realpath?

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

各自安好 2024-12-19 11:19:21

来源:http://php.net/manual/en/function.realpath.php

注意:运行的脚本必须对层次结构中的所有目录具有可执行权限,否则realpath()将返回FALSE。

因此,您的 Web 服务器还应该有权访问 pre-webroot 目录。

Source: http://php.net/manual/en/function.realpath.php

Note: The running script must have executable permissions on all directories in the hierarchy, otherwise realpath() will return FALSE.

So your web server should have access also to pre-webroot directories.

独守阴晴ぅ圆缺 2024-12-19 11:19:21

我目前在从命令行运行 PHP 时遇到了这个结果,但在 HTTP 请求中却没有。必须在某个地方进行配置或 $_SERVER 设置,如果我找到修复程序,将会更新。

I am currently experiencing this result when running PHP from command line, but not within an HTTP request. Got to be config or $_SERVER settings somewhere, will update if I find the fix.

孤者何惧 2024-12-19 11:19:21

我创建的路径不存在,请始终确保其格式正确。

这是我使用的路径:

realpath(MY_PATH . '../other_path');

其中 MY_PATH 没有尾随 /

The path I was creating didn't exist, make always sure that it's well formed.

This is the path I was using:

realpath(MY_PATH . '../other_path');

Where MY_PATH didn't have a trailing /.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文