【问题标题】:Linux/php require parent directoryLinux/php 需要父目录
【发布时间】:2012-01-27 21:52:13
【问题描述】:

我在 Ubuntu 11.10 上安装了 apache 服务器来托管我的本地网站,然后再从公司托管它。

我的网站根目录是“/home/a1a4a/www/”

我在 /home/a1a4a/www/account/account_info.php" 中有一个 php 文件

我希望他在“/home/a1a4a/www/include/fg_membersite.php”中包含一个文件

这是我从 account_info.php 所做的

require_once('./include/fg_membersite.php');

我得到了这个错误

Warning: require_once(./include/fg_membersite.php): failed to open stream: No such file or directory in /home/a1a4a/www/account/account_info.php on line 10 Fatal error: require_once(): Failed opening required './include/fg_membersite.php' (include_path='.:/usr/share/php:/usr/share/pear') in /home/a1a4a/www/account/account_info.php on line 10 

那么我做错了什么?怎么修 。 我拥有完全权限( sudo chown -R www-data )。

谢谢,节日快乐 :)

【问题讨论】:

    标签: php linux apache directory


    【解决方案1】:

    始终使用绝对路径,否则您将面临错误,具体取决于调用脚本。

    require_once('./include/fg_membersite.php');
    

    应该是

    require_once(dirname(dirname(__FILE__)).'/include/fg_membersite.php');
    

    【讨论】:

      猜你喜欢
      • 2013-01-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-10-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多