我正在開發一個應用程序並使用一個子文件夾作爲測試域。包括使用直接路徑而不是相對路徑dbconfig.php文件失敗
http://mywebsite/testing-folder
我DBCONFIG位於:
http://mywebsite/testing-folder/lib/dbconfig.php
,如果我包括文件: http://mywebsite/testing-folder/userarea/profile
它是罰款的相對路徑。如果我將它包含在直接路徑中,則會引發錯誤:
FATAL ERROR: Call to a member function prepare() on a non-object in...
$root = 'http://mywebsite/testing-folder/';
include '../../lib/dbconfig.php'; // This works
include $root.'lib/dbconfig.php'; // This does not
有什麼線索爲什麼?
請閱讀本文,您將找到答案:http://www.php.net/manual/en/function.include.php#52342 – vee