为什么 getcwd() 返回与本地密码不同的目录?
我正在 Ubuntu 服务器上做一些 PHP 的事情。
我正在工作的路径是 /mnt/dev-windows-data/Staging/mbiek/test_list 但 PHP 调用 getcwd()
返回 /mnt /dev-windows/Staging/mbiek/test_list(注意它是 dev-windows 而不是 dev-windows-data)。
任何地方都没有任何符号链接。
是否还有其他原因导致 getcwd()
从本地 pwd
调用返回不同的路径?
编辑
我想通了。 PHP 中的 DOCUMENT_ROOT 设置为 /mnt/dev-windows ,这会导致一切崩溃。
I'm doing some PHP stuff on an Ubuntu server.
The path I'm working in is /mnt/dev-windows-data/Staging/mbiek/test_list but the PHP call getcwd()
is returning /mnt/dev-windows/Staging/mbiek/test_list (notice how it's dev-windows instead of dev-windows-data).
There aren't any symbolic links anywhere.
Are there any other causes for getcwd()
returning a different path from a local pwd
call?
Edit
I figured it out. The DOCUMENT_ROOT in PHP is set to /mnt/dev-windows which throws everything off.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
@Mark
嗯,这太奇怪了! 你的
include_path
是什么 - 这可能会弄乱事情。 我个人已经放弃了它,转而使用内容,因为它太喜怒无常(或者我从来没有学会如何公正地对待它)。@Mark
Well that's just plain weird! What's your
include_path
- that could be messing thigns around. I've personally ditched it in favour of contants as it's just so temperamental (or I've never learned how to do it justice).@Ross
我想它出来并用解决方案更新了OP。
@Ross
I figured it out and updated the OP with the solution.
@Ross
我想getcwd() 返回文件系统路径而不是相对 url 路径。
无论哪种方式,事实仍然是路径 /mnt/dev-windows 不存在,而 /mnt/dev-windows-data 却存在。
@Ross
I thought that getcwd() was returning a filesystem path rather than a relative url path.
Either way, the fact remains that the path /mnt/dev-windows doesn't exist while /mnt/dev-windows-data does.
您在哪个文件中调用 getcwd(),该文件是否包含在您正在运行的文件中(例如运行index.php,包括包含gwtcwd() 的startup.php)。
您正在运行的文件是 /dev-windows/ 还是 /dev-windows-data/? 它适用于您实际运行的文件。
这是我当前项目的示例:
index.php
includes/construct.php
Which file are you calling the getcwd() in and is that file is included into the one you are running (e.g. running index.php, including startup.php which contains gwtcwd()).
Is the file you are running in /dev-windows/ or /dev-windows-data/? It works on the file you are actually running.
Here's an example of my current project:
index.php
includes/construct.php