Re: Include oddity
| From: | php4 at developersdesk dot com | Date: | Mon, 25 Sep 2000 20:14:24 +0000 |
| Subject: | Re: Include oddity | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-33692@lists.php.net to get a copy of this message | ||
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