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/featured/fashionWeek/database
<?php include(dirname(__FILE__).'/../config/Dbconfig.php') ;?>
しかし、ライブサーバーの public_html フォルダーの下に mywebsite フォルダーを配置したとき。次のエラーが発生します。
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