我正在开发一个应用程序,并将子文件夹用作测试域。
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包含文件。这是不对的,您应该包括将本地文件系统路径传递到include
或的文件require
。
您的根目录可能看起来像这样:
$root = '/var/www/mywebsite/testing-folder/';
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句