Re: HELP: Nested include(...)'s take relative paths not intuitively

From: Date: Tue, 10 Feb 2004 20:20:50 +0000
Subject: Re: HELP: Nested include(...)'s take relative paths not intuitively
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-177318@lists.php.net to get a copy of this message
From: "Alex Hogan" <Alex.Hogan@AlliedElec.com> > Are you saying that it's better not to use relative paths on include(...)'s, > require(...)'s and their (x)_once(...) cousins? > > That seems awkward to me. > > Why would I want to hard code a path, even if I was including additional > functionality from another file? Use whatever you're comfortable with because they both work. I'm just saying that I stay away from relative includes, myself. It's easy to just create a variable (or extract the data from $_SERVER) to find out the absolute path and just use that as a variable. Then you can do this: include($_CONF['path'] . '/test.php'); for example. I make similar $_CONF variables for the html root of the site $_CONF['html'] = 'http://www.bigredspark.com'; so that even the links in my html are full URLs instead of relative links. To each his own. ---John Holmes...

« previous php.general (#177318) next »