【发布时间】:2013-02-25 15:14:57
【问题描述】:
我在 c:\wamp\www\ 中有一个名为 mywebsite 的 php web 应用程序。 该文件夹由 featured/fashionWeek/database/Mysql.php 文件组成。我使用 dirname(FILE) 函数从根目录获取文件夹的路径,以便我可以将文件夹放置到实时服务器的 public_html 文件夹中的任何位置。
它在我的本地主机中运行良好。我在 wamp\www\mywebsite\featured\fashionWeek\database\Mysql.php 中有以下代码 include(dirname(FILE); 工作正常,返回此路径:C:/wamp/www/mywebsite /特色/时尚周/数据库
<?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
【问题讨论】:
-
我认为
include(dirname(__FILE__).'/config/Dbconfig.php')有效