我正在开发一个应用程序并使用一个子文件夹作为测试域。包括使用直接路径而不是相对路径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