문제

I have the following code (simplified) to add a path to my include paths (to temporarily fix an website with old code).

set_include_path(get_include_path() . PATH_SEPARATOR . '/foo/bar');

I have a settings file /foo/settings/settings.inc.php

Now when I have set the include path and I am in a file /foo/bar/members.php I want to include the settings file. So what the code does is:

include '../settings/settings.inc.php'

I would think that it would get that file now. But it doesn't. When I put the full path in the include it does work. eg: /foo/settings/settings.inc.php but there are a lot of files. And I thought that this would be a work around for that so I don't have to replace every file manually.

도움이 되었습니까?

해결책

I'd say you can't do that:

Files are included based on the file path given or, if none is given, the include_path specified. [...]

If a path is defined — whether absolute (starting with a drive letter or \ on Windows, or / on Unix/Linux systems) or relative to the current directory (starting with . or ..) — the include_path will be ignored altogether.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top