为什么在 PHP 中 realpath() 时该字符串会返回 false?

发布于 2024-08-23 04:52:20 字数 339 浏览 6 评论 0原文

这是我的字符串

$newPath = '/~new/assets/js/../packages/prettyphoto/js/jquery.prettyPhoto.js';

现在检查这个输出

var_dump($newPath); // string(64) "/~new/assets/js/../packages/prettyphoto/js/jquery.prettyPhoto.js"
var_dump(realpath($newPath)); // bool(false)

有人知道为什么这会对我返回 false 吗?

Here is my string

$newPath = '/~new/assets/js/../packages/prettyphoto/js/jquery.prettyPhoto.js';

Now check this output

var_dump($newPath); // string(64) "/~new/assets/js/../packages/prettyphoto/js/jquery.prettyPhoto.js"
var_dump(realpath($newPath)); // bool(false)

Does anyone know why this would be returning false on me?

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

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

发布评论

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

评论(3

折戟 2024-08-30 04:52:20

嘿,是提供手动链接<的人/a> 在你的 最后一个问题!不要只是链接它,而是阅读它。 :)

realpath() 在失败时返回 FALSE,例如,如果文件不存在。

Hey, you were the guy who provided the manual link in your last question! Don't just link it, read it. :)

realpath() returns FALSE on failure, e.g. if the file does not exist.

桃扇骨 2024-08-30 04:52:20

添加来查找

print_r(error_get_last());

您可以通过在声明后 。 手册页<中描述了可能的错误/a>.

You can find out by adding

print_r(error_get_last());

After your statement. The possible errors are described in the man page.

孤云独去闲 2024-08-30 04:52:20

快速浏览一下 php.net 的 realpath 定义可以看到以下注释,这可能是相关的:

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

A quick look on the php.net definition of realpath shows this note, which may be pertinent:

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

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