0

I am using xampp to develop my php application. Few days back I installed pear ti use DB abstraction. After that, I couldn't use include files from parent directory, however I can include from sub-driectories.

Here is what I see when I check my include path

.;E:\xampp\php\PEAR

I tried changed include path using set_include_path to the location where my files are stored, then the application failed to load Pear files.

Any help appreciated.

aarpey
  • 158
  • 1
  • 3
  • 15
  • 2
    How are you including the files? – deceze Oct 24 '11 at 05:02
  • @deceze the file I am trying to inclde resides in /htdocs/sms/application/configs/application.php, I am calling this file from /htdocs/sms/cce_desc/index.php and the code is require_once "../application/configs/application.php"; – aarpey Oct 24 '11 at 06:01

2 Answers2

1

Easiest way to prepend to the include path stack is...

set_include_path(implode(PATH_SEPARATOR, array(
    'path/to/app/includes',
    'path/to/any/other/includes',
    get_include_path()
)));
Phil
  • 157,677
  • 23
  • 242
  • 245
  • Thanks for the reply, I have got this (include_path='E:\xampp\htdocs\sms;.;E:\xampp\php\PEAR') but still failed to include file – aarpey Oct 24 '11 at 05:52
0

If you really want to use set_include_path, you can do it like this:

set_include_path(get_include_path().PATH_SEPARATOR.'path_to_parent');

Use the predefined constant DIRECTORY_SEPARATOR in case your code moves to a server that uses a different directory separator.

Personally if I needed to set the path specially for a particular site, I would try to set the path in the .htaccess file in the site's web root. It provides a more obvious place to look for site-wide configurations like the include_path. Here is the line you would put in the .htaccess file:

php_value include_path ".;E:\xampp\php\PEAR;path_to_parent"

or on a Linux server:

php_value include_path ".:some_path/PEAR:path_to_parent"
ghbarratt
  • 11,496
  • 4
  • 41
  • 41
  • Thanks for the reply, created a .htaccess file in my root dir. This is my parent directory path "E:\xampp\htdocs\sms" so I set avalue as follows php_value include_path ".;E:\xampp\php\PEAR;E:\xampp\htdocs\sms" . But it didn't work. The I changed value to include_path "E:\xampp\htdocs\sms" and it is working. But I need both values there. – aarpey Oct 24 '11 at 05:56