PHP 在 OSX 上包含路径问题

发布于 2024-12-11 01:40:38 字数 358 浏览 8 评论 0原文

我正在研究 Mac OSX Lion。这是一台新计算机,我正在努力再次设置我的开发环境。

当我尝试包含一个无意义的、不存在的文件时,页面加载正常。

$dir = dirname(__FILE__);

var_dump(include_once($dir . '/sg.php'));

// returns bool(false)

但是,当我尝试包含实际存在的文件时,页面根本无法加载。不用说,我的所有内容现在都无助地损坏了,左右抛出警告。

我已经检查了 php.ini 中的权限、所有权和 include_path。现在我陷入困境,需要一些帮助。

I'm working on Mac OSX Lion. This is a new computer and I'm working to set up my dev environment again.

When I try to include a nonsense, nonexistent file, the page loads fine.

$dir = dirname(__FILE__);

var_dump(include_once($dir . '/sg.php'));

// returns bool(false)

But when I try to include an actual, existent file, the page fails to load at all. Needless to say, all my includes are helplessly broken right now, throwing warnings left and right.

I've checked perms, ownership, and the include_path in php.ini. Now I'm just stuck and could use some help.

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

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

发布评论

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

评论(1

请帮我爱他 2024-12-18 01:40:38

您的问题可能不是工作不正常,而是 php.ini 中的 mysql 套接字文件错误。
尝试将其设置为/tmp/mysql.sock。
我的包含文件中有 mysql_connect,它在网页上报告了部分错误消息“没有这样的文件或目录”。当我尝试从命令行调用 index.php 时,它似乎找不到 mysql 套接字文件 - 不是包含的文件;-)
-马切伊

your problem is probably not improperly working include but wrong mysql socket file in php.ini.
Try to set it up to /tmp/mysql.sock.
I had mysql_connect in my included file and it reported partial error message "No such file or directory" on web page. When I tried to call index.php from commandline it appeared that it can't find mysql socket file - not the included file ;-)
-Maciej

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