Jump to content

Is there a way to include a file relative to another file...


tibberous

Recommended Posts

This one is hard to explain, so I'll use an example.

 

I have include files:

 

smptemail.php

actions/emailfunctions.php

 

And emailfunctions includes smptemail.php as ../smptemail.php. And this works, UNLESS emailfunctions.php if referenced from a directory other than the root one.

 

I can think of four solutions.

 

- Use symbolic links

- Copy the text of smptemail into emailfunctions

- Hard code paths

- include based on file_exists.

 

I'm going to probably go with four, but is there a better way to handle this? Like an include that looks for includes relative to the including file, not the main file?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.