Re: Include oddity
| From: | Szii | Date: | Tue, 26 Sep 2000 15:21:14 +0000 |
| Subject: | Re: Include oddity | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-33740@lists.php.net to get a copy of this message | ||
I've actually already worked around it, and gone 1 better...
include_path has a directory with a file called "const.h"
Inside that, I just put "directives/defines."
later,
require($g_ClassIncludePath . "\super_file.h");
Now I can move my subtrees around, and only have to modify
my const.h file and not every single file's header.
I -could- just put multiple directories in the include_path, but
I didn't want it to get huge and I'm not sure how much more
will have to be added at a later date.
-Szii
At 08:14 PM 9/25/00, php4@developersdesk.com wrote:
>Addressed to: Szii <szii@sziisoft.com>
> php-dev@lists.php.net
>
>** Reply to note from Szii <szii@sziisoft.com> Sat, 23 Sep 2000 00:42:21
-0700
>>
>> When using relative paths in a require() call, it's taking the base
>> directory to be the "execution directory" and not the directory that the
>> file is in. Is this expected/as designed? Should we just always use
>> absolute paths?
>>
>> base dir1 dir2 dir3
>>
>> in dir1/myclass.php4 require("../dir3/someinclude.h");
>>
>> from dir2, run "php ../dir1/myclass.php4 and the require() is trying to
>> now get ../dir1/someinclude.h from -dir2- instead of taking the base as of
>> where myclass.php4 is actually located and doing the require() call from.
>>
>> I can't find any reference to this is the docs. Is this "as designed?"
>
>
>As far as I can tell, include and require work from the directory the
>original script was executed from, not the directory that an included or
>required file resides in. It has been that way for a while, and I don't
>expect to see it change.
>
>You have two choices that I know of.
>
>
>1. use absolute paths.
>
>2. use the include_path option in php.ini or httpd.conf or .htaccess
>and list the directory with files to be included so they can be found
>with no path information required in the programs. See:
>
> http://www.php.net/manual/configuration.php
>
>
>2 is best.
>
>
>
>
>
>Rick Widmer
>Internet Marketing Specialists
>http://www.developersdesk.com
>