我在 c:\wamp\www\ 中有名为mywebsite的 php Web 应用程序。该文件夹由features/fashionWeek/database/Mysql.php文件组成。我使用 dirname( FILE ) 函数从根目录获取文件夹路径,以便可以将文件夹放置到实时服务器的 public_html 文件夹中的任何位置。
它在我的本地主机中运行良好。我在 wamp\www\mywebsite\featured\fashionWeek\database\Mysql.php 中有以下代码 include(dirname( FILE ); 工作正常,返回此路径:C:/wamp/www/mywebsite/featured/fashionWeek/database
<?php include(dirname(__FILE__).'/../config/Dbconfig.php') ;?>
但是当我将 mywebsite 文件夹放在实时服务器的 public_html 文件夹下时。它给出了以下错误:
Warning: include(/home/websitename/public_html/featured/fashionWeek/database/../config/Dbconfig.php) [function.include]: failed to open stream: No such file or directory in /home/websitename/public_html/featured/fashionWeek/database/Mysql.php on line 3
Fatal error: include() [function.include]: Failed opening required '/home/websitename/public_html/featured/fashionWeek/database/../config/Dbconfig.php' (include_path='.:/usr/share/pear:/usr/share/php') in /home/websitename/public_html/featured/fashionWeek/database/Mysql.php on line 3