I need to include a file in php so I do
$web_proc = '../res/proc'; //variable read from config file I can't change
//in my file
include_once($web_proc . '/check_sprache.php');
and PHP outputs:
Warning: include_once(../res/proc/check_sprache.php): failed to open stream: No such file or directory in /Users/user/Sites/site/res/pdf/rechnung.php on line 62
Warning: include_once(): Failed opening '../res/proc/check_sprache.php' for inclusion (include_path='.:') in /Users/user/Sites/site/res/pdf/rechnung.php on line 62
So I change the include path:
set_include_path(get_include_path() . PATH_SEPARATOR . dirname(__DIR__) . DIRECTORY_SEPARATOR);
and try it again, but PHP outputs:
Warning: include_once(../res/proc/check_sprache.php): failed to open stream: No such file or directory in /Users/user/Sites/site/res/pdf/rechnung.php on line 62
Warning: include_once(): Failed opening '../res/proc/check_sprache.php' for inclusion (include_path='.::/Users/user/Sites/site/res/') in /Users/user/Sites/site/res/pdf/rechnung.php on line 62
But if if I do
include_once(dirname(__DIR__). DIRECTORY_SEPARATOR . $pfadweb_proc . '/check_sprache.php');
it works. But this is no solution, since the included file includes more files with a relative path, so they are alse not found.
So either I misunderstand the PHP include path, or it's just trolling me.
Can anybody help?