Forum Moderators: coopster

Message Too Old, No Replies

PHP Include but in other directories?

         

Flurpal

11:58 pm on Apr 30, 2009 (gmt 0)

10+ Year Member



Hiya, I would like to know the syntax to include a file that rests in a different directory from which the file is. I know of the include function. Is there some function in PHP similar to the include "Virtual" function in SSI (.SHTML)?

eeek

12:03 am on May 1, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



You can always use the full path to the file.

rocknbil

2:57 pm on May 1, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Full path is more intuitive. You can set it as a constant:

define ('FULL_PATH','/path/to/includes/dir');

include (FULL_PATH . "/myinclude.php");

although I've seen this a lot. Contents of "path.php:"

.:./conf:./classes:

then where it's needed,

ini_set('include_path', @current(file('path.php')));