PDA

View Full Version : including global.php from different directory?


Jinovich
10-22-2010, 11:46 PM
Okay so I can include global.php from / where it exists like so.

/functions.php
include('./global.php');

Its fine with that.

/custompages/foobar/functions.php
However it seems to hate it when I include it as
include('../../global.php');
include('/home/base/public_html/global.php')

hates that errors out with:


Warning: require(./includes/class_bootstrap.php) [function.require]: failed to open stream: No such file or directory in /home/base/public_html/global.php on line 15

Fatal error: require() [function.require]: Failed opening required './includes/class_bootstrap.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/base/public_html/global.php on line 15

assuming that it is trying to look for these files from /custompages/foobar/instead of /.

How can I fix this,

I want to include global so I dont need to set up the mysql db connections.

sacobra
08-02-2011, 05:05 PM
Anyone can help with the above query?

I'm attempting to create a product and am planning to have all the files in packages/<product> rather than spread throughout the folders. However it seems to be difficult to include 'global.php' in the files !

kh99
08-02-2011, 05:11 PM
I think it will work if you chdir() to the directory with global in it. You can chdir() back after it's included. Like (using the example above):

$savedir = getcwd();
chdir('/home/base/public_html')
include('global.php');
chdir($savdir);