including files - paths

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

If I'm working on a project, I'll usually create a folder to contain all
the project files before uploading this to the root of the production
server.  The trouble is that if I do:
this looks at the root of local host, as it should and not at the root
of the working directory.  It means that if I want to use absolute
links, I have to change them before I upload.

Or am I missing something blindingly obvious?

I'm pretty sure this has been done before (FAQ entry material?), but not
for a while. :-)
Geoff Berrow  0110001001101100010000000110

Re: including files - paths

Geoff Berrow wrote:
Quoted text here. Click to load it

Change or extend your local configuration so that it reflects the
configuration at the remote server.

An easy way is creating a virtual host on your local box with a
documentroot pointing to the wannabe /...

Quoted text here. Click to load it
No, I don't think so


"He who asks a question is a fool for five minutes;
he who does not ask a question remains a fool forever"

Re: including files - paths

Hans van Kranenburg contained the following:

Quoted text here. Click to load it

Any idea where I might find instructions on how to do that?

Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs /

Re: including files - paths

Geoff Berrow wrote:
Quoted text here. Click to load it

   The quick solution is to use relative path (something like
.../foo.php or ./foo.php). But, if we use relative path for all
includes, it will hit performance. So, I use something like:

$CFG['project_path'] = '/home/foo/foo/';
//etc etc

require_once('../common/'); //relative to project
require_once($CFG['project_path'] . 'html/header.html'); //absolute
//etc etc...
require_once($CFG['project_path'] . 'html/footer.html'); //absolute

   As seen, only one path is relative. I even have a mechanism to auto
detect the project path in

Quoted text here. Click to load it

   Yes, this has to be included in FAQ. But, what could be an
appropriate question?

  <?php echo 'Just another PHP saint'; ?>
Email: rrjanbiah-at-Y!com    Blog: /

Site Timeline