...

View Full Version : Set an inclue path?



stfc_boy
11-22-2007, 01:42 PM
Hi All,

I have a file called header.php which I call into various pages on my site. In it I want to link to a file called process.php

Now this file lives in a folder in the top level called connections



<?php
ini_set('include_path', '/connections');
include('process.php');
?>


So the plan is if Iím calling header.php in a page from anywhere on a page that could be within a folder and then within another folder it will still work. However it does not?

Any ideas?

Thanks

phpBuddy
11-22-2007, 05:25 PM
There are 2 special functions for this.
Vaiants of ini_set() / ini_get()

http://php.net/get_include_path
http://php.net/set_include_path
Can be combined to (temporary just for script) add paths to the include setting.
<?php

// separator
$sep = ';'; // For Windows
//$sep = ':'; //for Unix, Linux

// new path(s) without ending slash
$addpath1 = 'C:/Apache/htdocs/connections';
$addpath2 = 'C:/Apache/htdocs/templates';
set_include_path( get_include_path() . $sep . $addpath1 . $sep . $addpath2 );

include('process.php'); // in the '/connections' directory

?>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum