RE: [PHP] require/include from a different directory
| From: | Jennifer Goodie | Date: | Mon, 31 Mar 2003 18:50:41 +0000 |
| Subject: | RE: [PHP] require/include from a different directory | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-141717@lists.php.net to get a copy of this message | ||
If the includes are within the website, using
$_SERVER[DOCUMENT_ROOT]/pathtofile/file is a good way to go.
-----Original Message-----
From: John W. Holmes [mailto:holmes072000@charter.net]
Sent: Saturday, March 29, 2003 2:10 PM
To: 'Greg Macek'; php-general@lists.php.net
Subject: RE: [PHP] require/include from a different directory
> > 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/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php