RE: [PHP] Includes and paths problem
| From: | John W. Holmes | Date: | Fri, 18 Apr 2003 22:08:11 +0000 |
| Subject: | RE: [PHP] Includes and paths problem | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-144442@lists.php.net to get a copy of this message | ||
> Is their a proper way to include files so that the paths are always
> correct.
> I have a login script as well as protected pages - and the protected
pages
> may be accessed from many possible locations on the site - the
included
> files may also have other included files - so what I have now is a
real
> mess. I'm constantly getting errors saying could not find this file or
> that
> file. Is there a way I can make sure these files are available from
> anywhere. Using an include directory works for some files, but I can't
put
> my whole site in there.
Use absolute paths. A common method is to define a variable:
$_CONF['path'] = '/home/web/www/site';
And use that in all of your includes.
Include($_CONF['path'] . '/security/security.php');
---John W. Holmes...
PHP Architect - A monthly magazine for PHP Professionals. Get your copy
today. http://www.phparch.com/