Helpful Information
Home
Categories
Contact us
Category: vB3 Programming Discussions
Help with includes
I always get errors like this when i include files from a different directory
Fatal error: Failed opening required './admin/config.php' (include_path='') in /home/win32asm/public_html/board/global.php on line 96
and it's because PHP doesn't take into account the directory according to the file i include but to the file from which i called the first include :(
How do I solution this?
Thank you very much
-H-
You use the chdir() function (Change Directory):
chdir("/full/path/to/your/forum");
require("./global.php");
ok, thx a lot :)
I'll try that.
I'm an experienced ASP and ColdFusion user but PHP is new to me.
Thx again :)
-H-
I prefer to change the scope of included files rather than changing directories...
ini_set("include_path", ini_get("include_path") . ":/path/to/includes");
It is important to have that colon! And there is no trailing slash.
PHP Docs: include_path (http://www.php.net/manual/en/configuration.php#ini.include-path), ini_get (http://www.php.net/manual/en/function.ini-get.php), ini_set() (http://www.php.net/manual/en/function.ini-set.php)
You can also do this in .htaccess:
php_value include_path .:/path/to/includes
privacy (GDPR)