RE: [PHP] require/include from a different directory
| From: | John W. Holmes | Date: | Sat, 29 Mar 2003 22:09:59 +0000 |
| Subject: | RE: [PHP] require/include from a different directory | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-141609@lists.php.net to get a copy of this message | ||
> > try using an absolute path.
>
> I've considered that route, but an issue I have with that is I do most
> of my development work on a machine that a different directory
structure
> than the production server (currently a Cobalt RaQ4), so the paths are
> different. Accommodating both would be a time consuming project for
me.
I always put it into a variable.
$_CONF['path'] = '/home/web/www/';
and then use that variable in all of your includes or requires. I also
make an HTML variable that's used in all links and images.
$_CONF['html'] = 'http://www.mysite.com/';
Sure, you have to get used to using this variable everywhere, but it
makes switching server pretty easy.
---John W. Holmes...
PHP Architect - A monthly magazine for PHP Professionals. Get your copy
today. http://www.phparch.com/